我一直试图将这个钉牢多年,但似乎无法弄明白。我只需要在每个<ul>
的中心水平和垂直对齐文本,但它不会发生。 JSFiddle
我哪里错了?
#HomeRight {
position: absolute;
width: 120px;
top: 120px;
bottom: 100px;
right: 0;
}
#HomeRight ul {
margin: 0;
padding: 0;
height: 100%;
display: table;
}
#HomeRight li {
display:table-cell;
float:left;
width:120px;
height:25%;
text-align:center;
vertical-align:middle;
background-color: rgba(0, 0, 0, 0.4);
border: 1px solid transparent;
background-clip: padding-box;
}
&#13;
<div id="HomeRight">
<ul>
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
</ul>
</div>
&#13;
答案 0 :(得分:0)
也许flex会比表更好的解决方案
#HomeRight ul {
width:100%;
height: 100%;
display: flex;
align-items:center;
justify-content:center;
}
答案 1 :(得分:0)
尝试使用此代码可能会对您有所帮助。
#HomeRight {
position: absolute;
width: 120px;
top: 120px;
bottom: 100px;
right: 0;
}
#HomeRight ul {
margin: 0;
padding: 0;
height: 100%;
display: table;
}
#HomeRight li {
display:table-cell;
float:left;
width:120px;
height:25%;
justify-content: center;
align-items: center;
background-color: rgba(0, 0, 0, 0.4);
border: 1px solid transparent;
background-clip: padding-box;
display: flex;
}
&#13;
<div id="HomeRight">
<ul>
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
</ul>
</div>
&#13;
答案 2 :(得分:0)
driver.findElement(By.cssSelector("a[id*='ProgramWizardBase_ctl00_HomePageHyperLink']")).click();
#HomeRight {
position: absolute;
width: 120px;
top: 120px;
right: 0;
}
#HomeRight ul {
margin: 0;
padding: 0;
height: 100%;
}
#HomeRight li {
list-style: none;
width:120px;
height:25%;
text-align:center;
background-color: rgba(0, 0, 0, 0.4);
border: 1px solid transparent;
background-clip: padding-box;
}
#HomeRight li:before {
content: '';
display: inline-block;
width: 1px;
vertical-align: middle;
height: 100%;
}