我希望左侧的元素与右侧的元素处于同一级别,这里是代码:https://jsfiddle.net/v5m6cv1u/
<div class="menu">
</p>Code too long<p>
</div>
答案 0 :(得分:1)
.menu h2 {
text-align: center;
font-size: 4vh;
text-transform: uppercase;
}
.menu h3 {
font-size: 3vh;
color: darkblue
}
.menu h4 {
padding: 0.2em 0em;
}
.menu .content {
padding: 3em 5em;
}
.ipsum {
list-style: none;
padding-bottom: 1em;
border-bottom: 1px solid #000000;
}
.menu p {
font-size: 1em;
}
.menu .vitae {
text-align: right;
color: brown
}
.meniu .vitae:after {
content: " VIT";
}
.menu .magna {
text-align: right;
color: darkslateblue;
font-size: 1.2em;
}
.menu .magna:after {
content: " MAG";
}
.menu ul {
columns: 2;
padding: 0;
margin: 0;
display: inline-block;
width: 100%;
}
.menu ul li {
display: inline-block;
}
.menu {
background-color: #FFFAE7;
}
.menu h1 {
color: #d00807;
font-size: 6em;
display: block;
text-align: center;
padding-top: 0.2em;
padding-bottom: 0.1em;
text-transform: uppercase;
}
&#13;
<div class="menu">
<h1>Lorem ipsum</h1>
<h2>Lorem ipsum dolor sit amet, et denique molestiae sit. </h2>
<div class="content">
<h3>Lorem</h3>
<ul>
<li class="ipsum dolor">
<h4>Dolor</h4>
<p>Nullam consequat, sem vitae rhoncus tristique, mauris nulla fermentum est, bibendum ullamcorper sapien magna et quam.</p>
<div class="vitae">9.5</div>
<div class="magna">320</div>
</li>
<li class="ipsum sit">
<h4>Sit</h4>
<p>Nullam consequat, sem vitae rhoncus tristique, mauris nulla fermentum est, bibendum ullamcorper sapien magna et quam.</p>
<div class="vitae">9.5</div>
<div class="magna">320</div>
</li>
<li class="ipsum amet">
<h4>Amet</h4>
<p>Nullam consequat, sem vitae rhoncus tristique, mauris nulla fermentum est, bibendum ullamcorper sapien magna et quam.</p>
<div class="vitae">9.5</div>
<div class="magna">320</div>
</li>
</ul>
</div>
</div>
&#13;
答案 1 :(得分:1)
您可以在ul
元素上使用此CSS,而不是使用li
上的列(它会产生不同的顺序,我不知道这是否还行为你?):
.menu ul li {
display: inline-block;
width: 45%;
box-sizing: border-box;
margin-right: 4%;
}
答案 2 :(得分:1)
简单的解决方案是使元素内联块
.ipsum {
[...]
display: inline-block;
}