我正在尝试自定义引导程序3.3.7 alert
类,以便添加进度条和内联项以实现类似的功能(虚线只是为了演示项目已对齐< /强>):
但是,我在右侧部分底部安装进度条时遇到问题,width
为100%。另外,我有问题将左侧部分的height
调整为100%并调整中间的图标。
我不确定我是否使用了正确的css策略,但这是我到目前为止所做的:
/* !important are just used to overide the bootstrap css in the snippet */
.alertContainer {
border-radius: 0 !important;
border-width: 0 !important;
padding: 0 !important;
height: auto !important;
position: absolute !important;
bottom: 15px !important;
left: 0;
right: 0;
margin: 0 auto !important;
width: 480px !important;
}
.leftPart {
display: inline-block !important;
height: 100% !important;
width: 32px;
font-size: 22px;
background-color: #31708f;
color: #d9edf7;
}
.leftPartContent {
padding: 0 5px;
}
.rightPart {
display: inline-block;
height: 100%;
width: 438px;
}
.rightPartContent {
display: flex;
align-items: center;
}
.close {
position: absolute !important;
right: 15px !important;
}
.progress {
margin-bottom: 0px !important;
bottom: 0px !important;
left: 0px !important;
width: 100% !important;
height: 5px !important;
}
&#13;
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div style="height:600px; width:600px;">
<div class="alertContainer alert alert-info" role="alert">
<div class="leftPart">
<span class="leftPartContent glyphicon glyphicon-info-sign"></span>
</div>
<div class="rightPart">
<div class="rightPartContent">
<button type="button" class="close" aria-label="Close"><span aria-hidden="true">×</span></button>
<div>
<span><strong>2018-15-06, 1:29 PM</strong></span><br>
<span>Hello world!</span>
</div>
</div>
<div class="progress">
<div class="progress-bar" role="progressbar" aria-valuenow="100" aria-valuemin="0" aria-valuemax="100" style="width: 100%;"></div>
</div>
</div>
</div>
</div>
&#13;
答案 0 :(得分:3)
/* !important are just used to overide the bootstrap css in the snippet */
.alertContainer {
border-radius: 0 !important;
border-width: 0 !important;
padding: 0 !important;
height: auto !important;
position: absolute !important;
bottom: 15px !important;
left: 0;
right: 0;
margin: 0 auto !important;
width: 480px !important;
display: table;
}
.leftPart {
text-align: center;
width: 55px;
font-size: 22px;
height: 75px;
background-color: #31708f;
color: #d9edf7;
display: table-cell;
vertical-align: middle;
}
.rightPart {
vertical-align: middle;
display: table-cell;
width: 438px;
}
.close {
position: absolute !important;
right: 15px !important;
}
.progress {
margin-bottom: 0 !important;
bottom: 0px !important;
left: 0px !important;
width: 100% !important;
height: 5px !important;
position: absolute;
border-radius: 0;
}
button.close {
line-height: 40px;
}
&#13;
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div style="height:600px; width:600px;">
<div class="alertContainer alert alert-info" role="alert">
<div class="leftPart">
<span class="glyphicon glyphicon-info-sign"></span>
</div>
<div class="rightPart">
<button type="button" class="close" aria-label="Close"><span aria-hidden="true">×</span></button>
<div class="col-sm-12">
<span><strong>2018-15-06, 1:29 PM</strong></span><br>
<span>Hello world!</span>
</div>
<div class="progress">
<div class="progress-bar" role="progressbar" aria-valuenow="100" aria-valuemin="0" aria-valuemax="100" style="width: 100%;"></div>
</div>
</div>
</div>
</div>
&#13;
你应该在引导后把你的css放好!重要的是没有必要