【发布时间】:2019-01-29 08:07:16
【问题描述】:
我一直试图让 div(名称和猜测)占据父容器的整个宽度。无论我尝试过什么,它们都只能达到容器的 98%。如果我将每一个设置为 50%,它们就会崩溃,然后一个容器就在另一个容器之上。他们目前设置为 49%。有什么想法吗?
.guess-section {
border: 1px solid red;
width: 50%;
background-color: #F7F7F7;
}
.guess-section article {
background-color: #FFF;
border: 2px solid #E0E0E0;
margin: 2%;
/*padding: 15px;*/
}
.r-low,
.r-high {
font-weight: 700;
text-decoration: underline;
}
.user-input {
display: inline-block;
border: 1px solid red;
height: 100px;
width: 49%;
}
.user-input input {
display: inline-block;
width: 100%;
}
<article class="set-challengers">
<p>The Current Range is <span class="r-low">1</span> to <span class="r-high">100</span></p>
<section class="challenger2">
<h3>Challenger 2</h3>
<div class="user-input">
<label for="name">
<span>Name</span></br>
<input type="text" id="name" name="user_name">
</label>
</div>
<div class="user-input">
<label for="name">
<span>Guess</span></br>
<input type="text" id="name" name="user_name">
</label>
</div>
</section>
<section class="challenger-buttons">
<button class="submit">SUBMIT GUESS</button>
<button class="reset">RESET GAME</button>
<button class="clear">CLEAR GAME</button>
</section>
</article>
【问题讨论】:
-
查看
box-sizing: border-box;,但不要执行它 - 理解它;) -
你应该试试
box-sizing: border-box。 -
我确实有
box-sizing: border-box,只发布了关于特定html的sn-p -
或许可以考虑使用CSS grid。