Get the App
SLTechnology News&Howtos  ›  Development  › 

How to use the float of a column of hyperlinks in CSS to create a horizontal menu

Shulou Source: shulou.com Published: 2022-06-01 12:35:35 10月03日 Update

This article is about how to use a column of hyperlink floats in CSS to create horizontal menus. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

Ul {float:left;width:100%;padding:0;margin:0;list-style-type:none;} a {float:left;width:7em;text-decoration:none;color:white;background-color:purple;padding:0.2em 0.6 emblem a:hover {background-color:#ff3300} li {display:inline} Link oneLink twoLink threeLink four

In the above example, we float the ul and an elements to the left. The li element is displayed as an inline element (there is no line break before and after the element). This allows the list to be arranged in a row. The width of the ul element is 100%, and each hyperlink in the list is 7em (7 times the current font size). We added colors and borders to make it more beautiful.

Thank you for reading! This is the end of the article on "how to use the floating of a column of hyperlinks in CSS to create a horizontal menu". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it out for more people to see!

Tags: Elements links floats horizontal menus content width more articles good practical beautiful one line examples can make font size article see knowledge Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Technology Xiaomi NVidia Redmi Huawei