我正在使用具有自己的CSS類的第三方庫。這是DOM的外觀:如何應用CSS類而不影響全局行爲
<div id="toast-container" class="toast-custom" aria-live="polite" role="alert">
<div class="toast toast-info" style="display: block;"> ....
這是我重寫對固定寬度
.toast-custom {
top: 0;
left: 30%;
width: 50%;
}
這已經是由框架
#toast-container > div {
position: relative;
pointer-events: auto;
overflow: hidden;
margin: 0 0 6px;
padding: 15px 15px 15px 50px;
width: 46%;
-moz-border-radius: 3px 3px 3px 3px;
-webkit-border-radius: 3px 3px 3px 3px;
border-radius: 3px 3px 3px 3px;
background-position: 15px center;
background-repeat: no-repeat;
-moz-box-shadow: 0 0 12px #999999;
-webkit-box-shadow: 0 0 12px #999999;
box-shadow: 0 0 12px #999999;
color: #ffffff;
opacity: 0.8;
-ms-filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=80);
filter: alpha(opacity=80);
}
提供的類的類
我無法修改dix的寬度而無需觸摸#toast-container > div
但如果我製作改爲#toast-container > div
它將產生全球影響。如何使用.toast-custom
進行必要的更改?
#toast-container.toast-custom –
正如Steve G.寫的,使用更大的CSS特性(瞭解這一點)。 – Christina
你想覆蓋'id =「toast-container」'或者'id =「toast-container」'的子項? –