w3schoolsから取得(リンクにアクセスして、どのように見えるかを確認してください):
<!DOCTYPE html>
<html>
<head>
<style>
ul
{
float:left;
width:100%;
padding:0;
margin:0;
list-style-type:none;
}
a
{
float:left;
width:6em;
text-decoration:none;
color:white;
background-color:purple;
padding:0.2em 0.6em;
border-right:1px solid white;
}
a:hover {background-color:#ff3300;}
li {display:inline;}
</style>
</head>
<body>
<ul>
<li><a href="#">Link one</a></li>
<li><a href="#">Link two</a></li>
<li><a href="#">Link three</a></li>
<li><a href="#">Link four</a></li>
</ul>
<p>
In the example above, we let the ul element and the a element float to the left.
The li elements will be displayed as inline elements (no line break before or after the element). This forces the list to be on one line.
The ul element has a width of 100% and each hyperlink in the list has a width of 6em (6 times the size of the current font).
We add some colors and borders to make it more fancy.
</p>
</body>
</html>
でul
、a
ですfloat:left;
。ここで、float は、次の要素がその周りを浮動する必要があることを示していますが、テキストはそうではありません。私は何が欠けていますか?
float
2 番目:から を削除ul
すると、テキストが周りに流れます。なんて深刻な一体?
inline
3 番目: from を削除しても何も起こりli
ません。それでも、float
fromを削除するa
と、要素の間に空白が置かれます。
なぜこれらのことが起こって、すべきことをしないのかを説明できる人はいますか?
(最新のクロム)