将3个容器相互串联编码

时间:2016-11-20 19:41:09

标签: html css

我试图让三列对齐,空间均匀,并且是一个完整的盒子。辩论边界,但我离题了。

到目前为止,我的代码看起来像这样:
HTML

<div id="container">
<div id="container-left">
<h3>Logo Design Services</h3>
<p>We work with you to design the perfect logo for your business, event,                                           or team.  The process puts you in the driver's seat as we work
to produce something you just cannot live without.  Whether we get it right on the first time, or the billionth, the price never changes.  
Logo design starts at just $100.00</p>
<h5><i>**Subject to change without notice or update to this site**</i>   </h5>
    <div id="container-center">
    <h3>Business Product Design</h3>
    <p>With a multitude of products, from <b>business cards, letterhead, namebadges, signage, vehicle signage, window decals, flyers, and more</b>.  
    We can design virtually anything you need in order to make your business look the way you always believed it would.  See <a    href="packagedeals.html">Package Deals</a>
    section to see each individual item, and get our "Start Me Up" Pacakge that includes the <b>Business cards, letterhead, namebadges and logo for $150.00</b></p>
        <div id="container-right">
        <h3>Promotional Product Design</h3>
        <p>Dave's Logo Designs does not print or manufactur promotional   products, but will research and help line you up with someone who can.  With   all promotional product
        items purchased, you get one copy of our interactive price/profit spreadsheet.  We do the work to put what you ordered and the quantities, so you set the price to see
        what your profit could be.  Design cost is based upon item needed.  <a href="contact.html">Contact us</a> for more information about    promotional product design</p>
        <h5>** Research fee may apply if we research the company.            Research fee is $10.00/hr.**</h5>
            </div>
        </div>
    </div>
</div>  

我的css:

#container {
width: 100%;
}   

#container-left {
display: inline-block;
float: left;
clear: left;
width: 33%;
padding: 25px;
margin-left: 175px;

}
#container-left h3 {
text-align: center;
}
#container-left p {
text-align: left;
}
#container-left h5 {
text-align: center;
color: red;
text-decoration: italic;
}
#container-center {
display: inline-block;
float: center;
clear: left;
width: 34%;
padding: 15px; 

} 
#container-center h3 {
text-align: center;
}
#container-center p {
text-align: left;
}
#container-right {
display: inline-block;
float: right;
width: 33%;
padding: 5px;
}   
#container-right h3 {
text-align: center;
}
#container-right p {
text-align: left;
}
#container-right h5 {
text-align: center; 
color: red;
}

似乎没有什么排队。我不确定为什么。谢谢你的帮助。 最重要的是总是缩进疯狂。如果我想要设置边框,我会辩论。另外,如果我使用相同的类标签(我现在知道它的ID,是否会将它放在会溢出的标签下面,还是会影响它的外观?

想要看起来像:                                     商业服务

  LOGO SERVICES              BUSINESS PRODUCT DESIGN         PROMOTIONAL
Blah等等等等等等等等等等等等等等等等等等等等等等等等等等等等等等等等等等等等等等等等等等等等等等等等等等等等等等等等等等等等等等等 blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah

                                SPORTS TEAM SERVICES

  LOGO DESIGN                 JERSEY DESIGN                MERCHANDISE
Blah等等等等等等等等等等等等等等等等等等等等等等等等等等等等等等等等等等等等等等等等等等等等等等等等等等等等等等等等等等等等 blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah

这有希望帮助你们。感谢您的帮助

3 个答案:

答案 0 :(得分:0)

清理HTML(你没有为每一个结束你的<div>)和CSS。

#container {
width: 100%;
}   
#container div {
  display: inline-block;
  width: 33%;
  box-sizing: border-box;
}
h3,h5 {
  text-align: center;
}
h5 {
color: red;
text-decoration: italic;
}
<div id="container">
<div id="container-left">
<h3>Logo Design Services</h3>
<p>We work with you to design the perfect logo for your business, event,                                           or team.  The process puts you in the driver's seat as we work
to produce something you just cannot live without.  Whether we get it right on the first time, or the billionth, the price never changes.  
Logo design starts at just $100.00</p>
<h5><i>**Subject to change without notice or update to this site**</i>   </h5>
  </div>
    <div id="container-center">
    <h3>Business Product Design</h3>
    <p>With a multitude of products, from <b>business cards, letterhead, namebadges, signage, vehicle signage, window decals, flyers, and more</b>.  
    We can design virtually anything you need in order to make your business look the way you always believed it would.  See <a    href="packagedeals.html">Package Deals</a>
    section to see each individual item, and get our "Start Me Up" Pacakge that includes the <b>Business cards, letterhead, namebadges and logo for $150.00</b></p></div>
        <div id="container-right">
        <h3>Promotional Product Design</h3>
        <p>Dave's Logo Designs does not print or manufactur promotional   products, but will research and help line you up with someone who can.  With   all promotional product
        items purchased, you get one copy of our interactive price/profit spreadsheet.  We do the work to put what you ordered and the quantities, so you set the price to see
        what your profit could be.  Design cost is based upon item needed.  <a href="contact.html">Contact us</a> for more information about    promotional product design</p>
        <h5>** Research fee may apply if we research the company.            Research fee is $10.00/hr.**</h5>
            </div>
        </div>

答案 1 :(得分:0)

使用flexbox,您可以执行以下操作:

.container {
  display: flex; /* Make the parent a flex containter */
}
.service {
  flex: 1; /* Distribute free space among flex items */
  padding: 1em;
}
.service h3 {
  text-align: center;
}
.service h5 {
  text-align: center;
  color: red;
}
.service--one h5 {
  font-style: italic;
}
<div class="container">
  <article class="service service--one">
    <h3>Logo Design Services</h3>
    <p>We work with you to design the perfect logo for your business, event, or team. The process puts you in the driver's seat as we work to produce something you just cannot live without. Whether we get it right on the first time, or the billionth, the
      price never changes. Logo design starts at just $100.00</p>
    <h5>**Subject to change without notice or update to this site**</h5>
  </article>
  <article class="service service--two">
    <h3>Business Product Design</h3>
    <p>With a multitude of products, from <strong>business cards, letterhead, namebadges, signage, vehicle signage, window decals, flyers, and more</strong>. We can design virtually anything you need in order to make your business look the way you always
      believed it would. See <a href="packagedeals.html">Package Deals</a> section to see each individual item, and get our "Start Me Up" Pacakge that includes the <strong>Business cards, letterhead, namebadges and logo for $150.00</strong>
    </p>
  </article>
  <article class="service service--three">
    <h3>Promotional Product Design</h3>
    <p>Dave's Logo Designs does not print or manufactur promotional products, but will research and help line you up with someone who can. With all promotional product items purchased, you get one copy of our interactive price/profit spreadsheet. We do the
      work to put what you ordered and the quantities, so you set the price to see what your profit could be. Design cost is based upon item needed. <a href="contact.html">Contact us</a> for more information about promotional product design</p>
    <h5>** Research fee may apply if we research the company.            Research fee is $10.00/hr.**</h5>
  </article>
</div>

修改你的代码你可以改进几件事情,将在下面列出:

  • 使用semantic HTML
  • 为每项服务使用<article> HTML标记。
  • 使用<strong>代替<b>,此处为why
  • 不要嵌套您的服务容器,他们需要共享同一个父容器。
  • 使用类而不是id来简化CSS并减少代码。
  • italicfont-style中使用的属性值,不在text-decoration中。

答案 2 :(得分:0)

--------------------------------风格-------------- -----------------------
    #pcontainer {显示:弯曲;箱尺寸:边界盒;     证明内容:空间周围;背景:#CCC;}     .container {width:30%;}     .container h3 {text-align:center;} ------------------------------- HTML ------------------ ----------------------

<div id="pcontainer">
<div class="container">
<h3>Logo Design Services</h3>
<p>We work with you to design the perfect logo for your business, event,                                           or team.  The process puts you in the driver's seat as we work
to produce something you just cannot live without.  Whether we get it right on the first time, or the billionth, the price never changes.  
Logo design starts at just $100.00</p>
<h5><i>**Subject to change without notice or update to this site**</i>   </h5>
  </div>
    <div class="container">
    <h3>Business Product Design</h3>
    <p>With a multitude of products, from <b>business cards, letterhead, namebadges, signage, vehicle signage, window decals, flyers, and more</b>.  
    We can design virtually anything you need in order to make your business look the way you always believed it would.  See <a    href="packagedeals.html">Package Deals</a>
    section to see each individual item, and get our "Start Me Up" Pacakge that includes the <b>Business cards, letterhead, namebadges and logo for $150.00</b></p>
  </div>
        <div class="container">
        <h3>Promotional Product Design</h3>
        <p>Dave's Logo Designs does not print or manufactur promotional   products, but will research and help line you up with someone who can.  With   all promotional product
        items purchased, you get one copy of our interactive price/profit spreadsheet.  We do the work to put what you ordered and the quantities, so you set the price to see
        what your profit could be.  Design cost is based upon item needed.  <a href="contact.html">Contact us</a> for more information about    promotional product design</p>
        <h5>** Research fee may apply if we research the company.            Research fee is $10.00/hr.**</h5>
            </div>

</div>