[英]Why are my circled div not inline with the rest of li?
I am creating my custom wizard. 我正在创建我的自定义向导。 I just try to put a "circled div" in my tabs.
我只是尝试在标签中添加一个“圈出的div”。 However my tabs are horizontal whereas my cirdcled div are.. ugly
但是,我的标签是水平的,而我的圆格是..丑陋的
https://jsfiddle.net/sme79azj/ https://jsfiddle.net/sme79azj/
html: 的HTML:
<ul>
<li>
<a><div class="wizard-steps-number">
<span class="number">1</span>
</div>Step number 1</a>
</li>
<li>
<a><div class="wizard-steps-number">2</div>Step number 2</a></li>
</ul>
Css 的CSS
ul{
list-style: none;
padding: 0px; }
li {
border: solid 1px lightgrey;
cursor: default;
color:black;
display: inline;
height:82px;
font-size: 12px;
margin: 0px;
opacity: 0.5;
padding-top: 15px;
padding-bottom: 15px;
padding-left: 25px;
padding-right: 25px;
}
.wizard-steps-number {
border-radius:1em;
border:solid 1px grey;
height:2em;
font-size:2em;
line-height:2em;
text-align:center;
color:black;
white-space: nowrap;
width:2em;}
Some properties can be applied to only block level elements. 某些属性只能应用于块级元素。 If you wants to apply them to
inline
elements then first make inline
elements inline-block
. 如果要将它们应用于
inline
元素,则首先将inline
元素设置为inline-block
。
Change display: inline
to display: inline-block
for li
and it will work with minor other changes as shown below: 更改
display: inline
display: inline-block
li
display: inline-block
,它将与其他较小的更改一起工作,如下所示:
ul{ list-style: none; padding: 0px; } ul li { border: solid 1px lightgrey; cursor: default; color:black; display: inline-block; height:82px; font-size: 12px; margin: 0px; opacity: 0.5; padding-top: 15px; padding-bottom: 15px; padding-left: 25px; padding-right: 25px; vertical-align: top; } .wizard-steps-number { border-radius:1em; border:solid 1px grey; height:2em; margin: 0 auto; font-size:2em; line-height:2em; text-align:center; color:black; white-space: nowrap; width:2em; }
<h1> My wizard doesn't have circle inline... :-( </h1> <ul> <li><a><div class="wizard-steps-number"><span class="number">1</span></div>Step number 1</a></li> <li><a><div class="wizard-steps-number">2</div>Step number 2</a></li> </ul>
without more explanation about what 'ugly' means, i made this snippet. 在没有更多解释“丑陋”的含义的情况下,我制作了此片段。 hope it is what you are looking for...let me know
希望这是您想要的...让我知道
use display:inline-block
on the li
and margin:0 auto
to center the circles 使用
display:inline-block
on li
和margin:0 auto
将圆圈居中
ul{ list-style: none; padding: 0px; } li { border: solid 1px lightgrey; cursor: default; color:black; display: inline-block; height:82px; font-size: 12px; margin: 0px; opacity: 0.5; padding-top: 15px; padding-bottom: 15px; padding-left: 25px; padding-right: 25px; } .wizard-steps-number { border-radius:1em; border:solid 1px grey; height:2em; font-size:2em; line-height:2em; text-align:center; color:black; white-space: nowrap; width:2em; margin:0 auto; }
<h1> My wizard doesn't have circle inline... :-( </h1> <ul> <li><a><div class="wizard-steps-number"><span class="number">1</span></div>Step number 1</a></li> <li><a><div class="wizard-steps-number">2</div>Step number 2</a></li> </ul>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.