我尝试在CSS / HTML中执行类似的操作:
每个“Box”应该是指向错误详细信息的链接。 文本和框内的红色div应水平居中,如图所示。
这是我的代码:JSFiddle
.outerDiv {
display: inline-block;
border-radius: 10px;
border: 2px solid #c3c3c3;
height: 100px;
width: 100px;
margin: 5px;
}
.innerDiv {
width: 50%;
height: 100%;
margin: 0 auto;
}
.errorLabel {
background-color: #a90329;
display: inline;
padding: .2em .6em .3em;
font-size: 75%;
color: #fff;
border-radius: .25em;
line-height: 1;
vertical-align: baseline;
font-weight: 700;
text-align: center;
white-space: nowrap;
box-sizing: border-box;
}
的答案之后
如果检测到两个小问题。
我能够通过将标签转换为块元素来解决第一个问题。 现在我正在寻找一种方法来确保所有标签与底部边框具有相同的空间。 (它应该看起来像图像,而不是小提琴)
答案 0 :(得分:2)
答案 1 :(得分:0)
我找到了解决问题的方法:JsFiddle
.outerDiv {
text-align: center;
float: left;
border-radius: 10px;
border: 2px solid #c3c3c3;
height: 100px;
width: 100px;
margin: 5px;
line-height: 50px;
}
.errorLabel {
display:inline-block;
vertical-align: bottom;
margin-bottom:7px;
width:84%;
background-color: #a90329;
padding: .2em .6em .3em;
color: #fff;
border-radius: .25em;
line-height: 1;
font-weight: 700;
white-space: nowrap;
box-sizing: border-box;
}