简体   繁体   English

填充 HTML/CSS 中的额外空间

[英]Filling Extra Space in HTML/CSS

How do I fill that circled space?我如何填充那个圆圈空间? I want to know how to fill the rest of the blue area with white background-color.我想知道如何用白色背景色填充蓝色区域的其余部分。

I tried increasing the padding, but that moved the price lower and lower and to the left a little each time I increased the padding.我尝试增加填充,但每次我增加填充时,价格都会越来越低,并向左移动一点。

在此处输入图片说明

My HTML looks like this..我的 HTML 看起来像这样..

 section { background-color: white; } #repair-tagline h1 { background-color: white; font-family: 'Open Sans Condensed', sans-serif; letter-spacing: 0.2rem; font-size: 3rem; text-align: center; padding: 40px 0 40px 0; } .repair-option { background-color: rgb(0, 0, 77); width: 80%; padding: 50px 50px 50px 50px; margin: 0px auto 50px auto; } .repair-type, .repair-price { display: inline-block; color: white; } .repair-type { font-size: 2rem; } .repair-price { float: right; background-color: white; border: 1px solid black; color: black; font-size: 2rem; }
 <section> <div class="repair"> <div id="repair-tagline"> <h1>Choose Your Vacuum Cleaner Repair Option:</h1> </div> <div class="repair-option"> <div class="repair-type"> <h1>Belt Repair</h1> </div> <div class="repair-price"> <h1>$10.00</h1> </div> </div> <div class="repair-option"> <div class="repair-type"> <h1>Brush-Roll Repair</h1> </div> <div class="repair-price"> <h1>$20.00</h1> </div> </div> </div> </section>

Remove the padding from the class of repair-option and add individual paddings to the 2 child divs ( repair-type and repair-price ).repair-option类中删除填充并将单个填充添加到 2 个子 div( repair-typerepair-price )。 That way, each of those had individual paddings which means the background-color corresponds to the div.这样,每个都有单独的填充,这意味着背景颜色对应于 div。

The padding for .repair-price may look weird, but I just did that because it wasn't lining up. .repair-price的填充可能看起来很奇怪,但我这样做是因为它没有排队。 You can change all the paddings to how you wish.您可以将所有填充更改为您希望的方式。

 section { background-color: white; } #repair-tagline h1 { background-color: white; font-family: 'Open Sans Condensed', sans-serif; letter-spacing: 0.2rem; font-size: 3rem; text-align: center; padding: 40px 0 40px 0; } .repair-option { background-color: rgb(0, 0, 77); width: 80%; padding: 0px; margin: 0px auto 50px auto; } .repair-type, .repair-price { display: inline-block; color: white; } .repair-type { font-size: 2rem; padding: 10px; } .repair-price { float: right; background-color: white; border: 1px solid black; color: black; font-size: 2rem; padding: 10px 0px 8px 0px; }
 <section> <div class="repair"> <div id="repair-tagline"> <h1>Choose Your Vacuum Cleaner Repair Option:</h1> </div> <div class="repair-option"> <div class="repair-type"> <h1>Belt Repair</h1> </div> <div class="repair-price"> <h1>$10.00</h1> </div> </div> <div class="repair-option"> <div class="repair-type"> <h1>Brush-Roll Repair</h1> </div> <div class="repair-price"> <h1>$20.00</h1> </div> </div> </div> </section>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM