【问题标题】:There is a white space underneath the button in the detail box in htmlhtml中详细信息框的按钮下方有一个空格
【发布时间】:2020-01-28 13:41:32
【问题描述】:

我将父元素的宽度设置为100%。然后,我决定父元素包含的两个元素的宽度各为 50% 之后,我将第一个元素的背景颜色设置为白色,另一个设置为黑色。第一个元素下有一个奇怪的空白。但是我修改了第一个盒子的大小,它仍然存在。有谁知道如何删除那个?

.container {
  width: 100%;
}

.infoBox {
  width: 100%;
  height: 400px;
  margin: 0;
}

.detailBox {
  width: 50%;
  margin: 0;
  padding: 0;
  float: left;
  font-size: 16pt;
  background: black;
}

.detailBox2 {
  width: 50%;
  margin: 0;
  padding: 0;
  float: right;
  font-size: 16pt;
  background: white;
}

.post {
  width: 90%;
  padding: 0 5%;
}

.detailBox .post {
  color: white;
}

.detailBox2 .post {
  color: black;
}

.post h1 {
  margin: 2% 0;
}

.detailBox button {
  padding: 4.65% 12%;
  background: white;
  border-radius: 30px;
  color: #688dc1;
  font-size: 10pt;
  border: none;
  border-color: #688dc1;
  letter-spacing: 0.04em;
  text-align: center;
  font-weight: bold;
}

.detailBox2 button {
  padding: 4.65% 12%;
  background: white;
  border-radius: 30px;
  color: #688dc1;
  font-size: 10pt;
  border-color: #688dc1;
  letter-spacing: 0.04em;
  text-align: center;
  font-weight: bold;
}
<div class="container">
  <section id="infoBox">
    <section class="detailBox">
      <div class="post">
        <h1>About me</h1>
        <p>I studied editiorial, graphic, Western Art, web design and developement at college in Canada. After working at an American and Canadian companies, I finally established my own design comapny, JoeyNamiki Design. I discovered that I want to create
          a large range of designs. In addition, I also want to develop as many websites as I can. </p>
        <button>Learn More</button>
      </div>
    </section>
    <section class="detailBox2">
      <div class="post">
        <h1>About you</h1>
        <p>If you are looking for a web agency that can redesign and create your company's website with a well-ordered process, you should ask me what you want to do through email. With a clear menu, you can immediately tell how much are the costs for your
          website and other options such as graphic, logo, poster designs. Let's talk together about your future website!</p>
        <button>Learn More</button>
      </div>
    </section>
  </section>

【问题讨论】:

  • 有点困惑,我没有看到空格,你能给我们截图吗?所以我们正在努力帮助你。 :)
  • @Jaydeep Patel 哦不!解决了!完成。对不起。我没有问题!
  • 如果你解决了,请删除问题-对其他人无用
  • @mplugjan 我以为我昨天解决了,但今天有时我可以看到像照片一样的空间......我不知道为什么
  • 我认为问题在于句子的长度。我在每个盒子里放了相同数量的句子。实际上,我想知道是否有其他方法可以做到这一点......

标签: html css css-float whitespace


【解决方案1】:
Change width as i changed  width: 30%;

试试下面的sn-p。

.container{
    width: 100%; 
}
.infoBox {
    width: 100%;
    height: 400px;
    margin: 0;    
}
.detailBox {
    width: 30%;
    margin:  0;
    padding: 0;
    float: left;
    font-size: 16pt;
    background: black;
}
.detailBox2 {
    width: 50%;
    margin: 0;
    padding: 0;
    float: right;
    font-size: 16pt;
    background: white;
}

.post {
    width: 90%;
    padding: 0 5%;
}
.detailBox .post {
    color: white;
}
.detailBox2 .post {
    color: black;
}
.post h1{
    margin: 2% 0;    
}
.detailBox button {
    padding: 4.65% 12%;
    background: white;
    border-radius: 30px;
    color: #688dc1;
    font-size: 10pt;
    border: none;
    border-color: #688dc1;
    letter-spacing: 0.04em;
    text-align: center;
    font-weight: bold;
}
.detailBox2 button {
    padding: 4.65% 12%;
    background: white;
    border-radius: 30px;
    color: #688dc1;
    font-size: 10pt;
    border-color: #688dc1;
    letter-spacing: 0.04em;
    text-align: center;
    font-weight: bold;
}
<div class="container">
          <section id="infoBox">
            <section class="detailBox">
                 <div class="post">
                  <h1>About me</h1>
                     <p>I studied editiorial, graphic, Western Art, web design and developement at college in Canada. After working at an American and Canadian companies, I finally established my own design comapny, JoeyNamiki Design. I discovered that I want to create a large range of designs. In addition, I also want to develop as many websites as I can. </p>
                  <button>Learn More</button>
                </div>
            </section>
            <section class="detailBox2">
                 <div class="post">
                  <h1>About you</h1>
                  <p>If you are looking for a web agency that can redesign and create your company's website with a well-ordered process, you should ask me what you want to do through email. With a clear menu, you can immediately tell how much are the costs for your website and other options such as graphic, logo, poster designs. Let's talk together about your future website!</p>
                  <button>Learn More</button>
                </div>
                </section>    
            </section>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-07-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-07-19
    相关资源
    最近更新 更多