This article shares with you two methods of setting up horizontal navigation structures, mainly using list structures. The method combines a block structure with an inline structure. Here we first introduce the difference between block elements and inline structures. (1) The block structure can set attributes such as line height, width (width, height), margin (margin, padding), and border. Inline elements can only set line height, left and right margins, but do not have attributes such as margins, top and bottom padding, and borders. (2) The block structure is more dominant and does not share a row with other elements. Inline elements can be nested within other elements. Common block elements include ul, ol, p, form, etc. Common inline elements include meta, img, span, h1-h6, label, etc. But sometimes, in order to make the block structure have the characteristics of inline elements, or to make the inline elements have the characteristics of block elements, the two are combined. Let's take an example of making an inline element have block element characteristics: the a tag is one of the most important inline tags. Users can access the corresponding page according to the link it specifies. In order to make the elements under the a tag more beautiful, we want to set some attributes for this link, including borders, margins, background colors, etc. We know that these attributes are only available to block structures, so at this moment we want to continue using the inline tag a to accommodate the link content, but we also hope that this inline element can also have the relevant attributes of the block structure. We can solve this problem by setting "a{display:block}". Similarly, when we want to use a list to achieve the purpose of setting up horizontal navigation, we hope that each row of the list can be displayed on the same line. At this time, we can also achieve this goal by combining block structure with inline structure. We just need to add one line of code to the list: list{display:inline;} Method 2 uses the float attribute setting. The float attribute can be set to float in two directions, including left and right. To set horizontal navigation, we float the list horizontally to the left. We float it to the left because we hope that after setting the floating, the order of navigation will be horizontal from left to right, that is, from left to right, it is navigation one to navigation four, which is more in line with the habits of more users. Code: XML/HTML CodeCopy content to clipboard
The above is the full content of this article. I hope it will be helpful for everyone’s study. Original text: http://www.cnblogs.com/xiaoqqmin/p/5317551.html |
<<: CSS isolation issue in Blazor
>>: MySQL 8.0 can now handle JSON
The google.html interface is as shown in the figur...
Table of contents The node version does not corre...
Copy code The code is as follows: <select> ...
When it comes to switching directories under Linu...
I heard that there is an interview question: How ...
Table of contents Proper use of indexes 1. Disadv...
Table of contents 1. Differences between the two ...
Table of contents Uncontrolled components Control...
type is the control used for input and output in t...
This article example shares the specific code for...
VMware version: VMware-workstation-full-16 VMware...
Table of contents Nginx load balancing configurat...
This article example shares the specific code of ...
Table of contents Complex query and step-by-step ...
In previous development, we used the default attr...