0
次のHTMLコードでは、プロパティを与えるために1つだけを使用するのではなく、2つのdivを1つのクラスに、もう1つのIDでIDを使用するのはなぜですか?同じセクションの2つのdiv
.header {
background-image: url("https://s3.amazonaws.com/codecademy-content/courses/web-101/unit-5/htmlcss1-img_canyon.jpeg");
background-position: center center;
background-size: cover;
height: 700px;
width: 100%;
}
#header-text {
margin: 0 auto;
position: relative;
text-align: center;
top: 25%;
width: 60%;
}
<div class="header">
<div id="header-text">
<h1>Travel Like Never Before</h1>
<h2>Whether you're looking for adventure or luxury, let us help you plan your perfect getaway.</h2>
</div>
</div>
'class'は他の' divs'でも再利用できますが、 'id'は一意であり他の要素には使用できません。そのすべての個人的な好み。もっと読むhttps://css-tricks.com/the-difference-between-id-and-class/ – tech2017
実際の仕事は何でしたか? –
"2つの部門を使用していますか?_" 100万の異なる理由の1つになる可能性があります。 – csmckelvey