私はその数がCSSセレクターに含まれていないことがわかりました。なぜCSSのセレクタでIDを数値にすることができないのですか?
<!DOCTYPE html>
<html>
<style type="text/css">
div{width:350px;word-wrap:break-all; }
#1{float:left;}
</style>
<div class="up">
<p><img id="1" src="http://i.imgur.com/Vt9ni32.jpg?1" /> Web graphics are visual representations used on a Web site to enhance or enable the representation of an idea or feeling, in order to reach the Web site user. Graphics may entertain, educate, or
emotionally impact the user, and are crucial to strength of branding, clarity of illustration, and ease of use for interfaces. Examples of graphics include maps, photographs, designs and patterns, family trees, diagrams, architectural or engineering
blueprints, bar charts and pie charts, typography, schematics, line art, flowcharts, and many other image forms.
</p>
</div>
</html>
CSSセレクタ内の数字は、右のテキストが上から始まっていない場合には、ギャップがここに残って、あなたがid=2
または他の番号にid=1
を変更するために、それは使用されません#1{float:left;}
を#2{float:left;}
に変更すると、その隙間はそのまま残ります。
数字を単語に変更すると、次のようにギャップが消えます。あなたが数字で始まるIDを使用してはならないHTML 4では
<!DOCTYPE html>
<html>
<style type="text/css">
div{width:350px;word-wrap:break-all; }
#test{float:left;}
</style>
<div class="up">
<p><img id="test" src="http://i.imgur.com/Vt9ni32.jpg?1" /> Web graphics are visual representations used on a Web site to enhance or enable the representation of an idea or feeling, in order to reach the Web site user. Graphics may entertain, educate,
or emotionally impact the user, and are crucial to strength of branding, clarity of illustration, and ease of use for interfaces. Examples of graphics include maps, photographs, designs and patterns, family trees, diagrams, architectural or engineering
blueprints, bar charts and pie charts, typography, schematics, line art, flowcharts, and many other image forms.
</p>
</div>
</html>
そのないIDは数字にすることはできませんことを。任意の英数字の値を指定できますが、数字で始めることはできません。文字で始める必要があります。 ref:https://msdn.microsoft.com/en-us/library/ms533880(v=vs.85).aspx – zipzit
注:私は[Mozilla](https://developer.mozilla.org/en)から参照してください'この制限がHTML5で取り除かれました、IDは互換性のために文字で始まるべきです。 'と言われましたが、これは他のものの純粋な複製であると私は信じています。答えはstackoverflowで。それを見つけました:http://stackoverflow.com/questions/70579/what-are-valid-values-for-the-attribute-in-html/79022#79022 – zipzit