我需要在同一個div類中使用一個項目,在本例中爲img,但具有不同的定義。同一div類中相同項的兩個定義
例子:
section .row img {
margin: 0 0 30px;
width: 100%;
border: 4px solid #18a00e;
}
section .row img {
margin: 0 0 30px;
border: 4px solid #18a00e;
max-height: 300px;
}
如何創建和使用該兩個定義沒有最後一個覆蓋以前的? 謝謝。
後來編輯(更多信息):
//this is the html code scenario 1 where I need the width: 100%//
<section class="container">
<div class="row">
<figure class="col-lg-4 col-md-4 col-sm-4 col-xs-4">
<img src="img/m3.jpg"/>
</figure>
</div>
</section>
//this is the html code for scenario 2, where I need max-height: 300px//
<section class="jumbotron">
<div class="unlockedl">
<div class="row">
<img src="img/pm1.jpg"/>
</div>
</div>
</section>
這取決於您的標記。你也可以發佈你的標記嗎? –
您需要添加額外/不同的選擇器來引用其中一個或另一個。這些不需要是類。但是如果沒有看到這兩個元素的HTML,就不可能推薦一個合適的解決方案。 – Alvaro
我是新來的編碼,使用bootstrap。我不知道標記是什麼。 – Claudiu