中心盒不能 - 愚蠢的问题?

时间:2015-10-24 22:32:13

标签: html css

我正试图将div中的3x链接称为“了解更多”。

我尝试过保证金:自动,宽度33%,文本对齐:中心,似乎没有任何效果!

有人可以帮助我,因为这让我发疯了!

以下是HTML:

    <!DOCTYPE html>
<html>
  <head>
    <link href='https://fonts.googleapis.com/css?family=Raleway:400, 600' rel='stylesheet' type='text/css'>
  <link rel='stylesheet' href='style.css'/>
  </head>
  <body>
    <div class="header">
      <div class="container">
        <ul class="nav">
          <li> About </li>
          <li> Work </li>
          <li> Team </li>
          <li> Contact </li>
        </ul>
      </div>
    </div>

    <div class="jumbotron">
      <div class="container">  
        <div class="main">
          <h1>We are Broadway</h1>
          <a href"https://localhost:8000/" class="btn-main"> Get Started </a>

        </div>
      </div>
    </div>

    <div class="supporting">
      <a href""> Learn more </a>
      <a href""> Learn more </a>
      <a href""> Learn more </a>
      <div class="container">
        <div class="col">
          <img src="https://s3.amazonaws.com/codecademy-content/projects/broadway/design.svg">
          <h2>Design</h2>
          <p>Make your projects look great and interact beautifully.</p>

        </div>
        <div class="col">
          <img src="https://s3.amazonaws.com/codecademy-content/projects/broadway/develop.svg">
          <h2>Develop</h2>
          <p>Use modern tools to turn your design into a web site</p>

        </div>
        <div class="col">
          <img src="https://s3.amazonaws.com/codecademy-content/projects/broadway/deploy.svg">
          <h2>Deploy</h2>
          <p>Use modern tools to turn your design into a web site</p>

        </div>
      </div>
      <div class="clearfix"></div>
    </div>

    <div class="footer">
      <div class="container">
        <p>&copy; Broadway 2015</p>
      </div>
    </div>
  </body>
</html>

以下是CSS:

    html, body {
  margin: 0;
  padding: 0;
}

html { 
  background: url(http://www.freebiesgallery.com/wp-content/uploads/2013/08/light-blue-background-3.jpg) no-repeat center center fixed; 
  -webkit-background-size: cover;
  -moz-background-size: cover;
  -o-background-size: cover;
  background-size: cover;
}

.container {
  max-width: 940px;
  margin: 0 auto;
  padding: 0 10px;
}

.jumbotron {
  height: 800px;
}

.nav {
  margin: 0;
  padding: 20px 0;
}
.nav ul {
    text-align: center;  
}

.nav li {
  color: #fff;
  font-family: 'Raleway', sans-serif;
  font-weight: 800;
  font-size: 12px;
  display: inline-block;
  padding: 40px;
  text-align: center;
  margin-left: 10%;

}

.nav li:hover {
  color: #008080;
  font-size: 14px;
  font-weight: bold;
}

.main {
  position: relative;
  top: 180px;
  text-align: center;
}

.main h1 {
  color: #333;
  font-family: 'Raleway', sans-serif;
  font-weight: 600;
  font-size: 70px;
  margin-top: 0;
  margin-bottom: 80px;
  text-transform: uppercase;
}

.btn-main {
  background-color: #333;
  color: #fff;
  font-family: 'Raleway', sans-serif;
  font-weight: 600;
  font-size: 18px;
  letter-spacing: 1.3px;
  padding: 16px 40px;
  text-decoration: none;
  text-transform: uppercase;
}

.supporting {
  padding-top: 80px;
  padding-bottom: 100px;
}

.supporting a {
  background-color: #FFFFFF;
  border-style: solid;
  border-color: #333333;
  font-family: 'Raleway', sans-serif;
  font-weight: 600;
  font-size: 14px;
  letter-spacing: 1px;
  padding: 12px 30px;
  text-decoration: none;
  text-transform: uppercase;
  display: inline-block;
  margin: 30px;
  text-align: center;
  width: 10%;
}
.supporting .col {
  float: left;
  width: 33%;
  font-family: 'Raleway', sans-serif;
  text-align: center;
}

.supporting img {
  height: 32px;
}

.supporting h2 {
  font-weight: 600;
  font-size: 23px;
  text-transform: uppercase;
}

.supporting p {
  font-weight: 400;
  font-size: 14px;
  line-height: 20px;
  padding: 0 50px;
  margin-bottom: 40px;
}

.clearfix {
  clear: both;
}

.footer {
  background-color: #333;
  color: #fff;
  padding: 30px 0;
}

.footer p {
  font-family: 'Raleway', sans-serif;
  text-transform: uppercase;
  font-size: 11px;
}

@media (max-width: 500px) {
  .main h1 {
    font-size: 50px;
    padding: 0 40px;
  }

  .supporting .col {
    width: 100%;
  }
}

.header {
    background-color: #333333; 
}

3 个答案:

答案 0 :(得分:0)

你把链接放在一个单独的div中,然后像这样对文本对齐:

<div class="lm-links">
  <a href""> Learn more </a>
  <a href""> Learn more </a>
  <a href""> Learn more </a>
  </div>

CSS:

 .lm-links {
margin: 0 auto;
text-align: center;    }

答案 1 :(得分:0)

好吧,想想我有你需要的东西。我不得不调整一些其他的东西来让他们排队。

.supporting {
padding-top: 80px;
padding-bottom: 100px;
position: relative;
left: 200px;
}

.supporting img {
height: 32px;
position: relative;
left: -210px;
}

.supporting h2 {
font-weight: 600;
font-size: 23px;
text-transform: uppercase;
position: relative;
left: -210px;
}

.supporting p {
font-weight: 400;
font-size: 14px;
line-height: 20px;
padding: 0 50px;
margin-bottom: 40px;
position: relative;
left: -210px;
}

答案 2 :(得分:0)

我做了一件事,即在另一个元素(图)中添加3x链接并应用此元素text-align:center

CSS:

.supporting figure {
            text-align: center;
        }

HTML:

<div class="supporting">
            <figure>
                <a href""> Learn more </a>
                <a href""> Learn more </a>
                <a href""> Learn more </a>
            </figure>
            <div class="container">