繁体   English   中英

在 css 中排列文本时遇到问题

[英]Having trouble lining up text in css

我对 HTML5 和 CSS 还很陌生,因此决定尝试制作自己的网站来让我的脚湿透。 我希望制作一个更简单的http://www.igshoutouts.com/版本来宣传我的 Instagram 页面。 我在排列方框时遇到问题,例如将媒体、关注者和关注与数字一起放入方框中。 我如何获得媒体、关注者和关注以及每个框中的数字。 我似乎也无法将文本排列在页面上我想要的位置。 我被告知不要将文本放在 CSS 中,所以我如何将它们全部放入

我附上了我的代码,请让我知道它到目前为止的样子。

 /* Base Styles -------------------- */ * { box-sizing: border-box; } body { color: #878787; margin: 0; font: 1em/1.5 "Helvetica Neue", Helvetica, Arial, sans-serif; } h1 { font-size: 5.625rem; /* 90px/16px */ font-family: serif; color: rgba(255, 255, 255, 1); text-transform: uppercase; font-weight: bold; line-height: 1.3; } img { max-width: 100% margin-bottom: 20px; } /* Pseudo-classes ------------------ */ a:link { color: rgb(255, 169, 73); text-decoration: none; } a:visited { color: lightblue; } a:hover { color: rgba(255, 169, 73, .4); } a:active { color: lightcoral; } .flex-item { color: black; font-size: 14px; font-weight: bold; } /* Main Styles --------------------- */ .main-header { background-color: blue; padding-top: 20px; height: 300px; box-sizing: border-box; } .title { color: white; font-size: 1.625rem; /* 26px/16px */ } .intro { font-size: 1.25em; /* 20px/16px */ line-height: 1.6; } .primary-content, .main-header, .main-footer { text-align: center; } .primary-content { padding-top: 25px; padding-bottom: 95px; } .secondary-content { padding-top: 80px; padding-bottom: 70px; border-bottom: 2px solid #dfe2e6; } .callout { font-size: 1.25em; border-bottom: 3px solid; padding: 0 9px 3px; margin-top: 20px; display: inline-block; } .main-footer { padding-top: 60px; padding-bottom: 60px; border-bottom: 10px solid #ffa949; } .t-border { border-top: 2px solid #dfe2e6; } /* Layout Styles ------------------ */ .primary-content, .secondary-content { width:10%; box-sizing: border-; padding-left: 10px; padding-right: 50px; margin: left-side; max-width: 50px; } .box { background: url(igbodybuildingworld2.jpg); background-size: 150px; background-repeat: no-repeat; background-position: top center; float: left; color: black; font-weight: bold; font-size: 18px; text-align: center; line-height: 300px; background-color: white; width: 280px; margin-left: 10px; margin-right: 10px; margin-top: 30px; padding: 5px; border: 1px solid black; height: 400px; } .box2 { background: url(absmotivation1012.jpg); background-size: 250px; background-repeat: no-repeat; background-position: top center; float: left; color: black; font-weight: bold; font-size: 18px; text-align: center; line-height: 500px; background-color: white; width: 280px; margin-left: 10px; margin-right: 10px; margin-top: 30px; padding: 5px; border: 2px solid black; height: 400px } .box3 { background: url(instafitnesslifestyle1012.jpg); background-size: 250px; background-repeat: no-repeat; background-position: top center; float: left; color: black; font-weight: bold; font-size: 18px; text-align: center; line-height: 500px; background-color: white; width: 280px; margin-left: 10px; margin-right: 10px; margin-top: 30px; padding: 5px; border: 2px solid black; height: 400px } .box4 { background: url(absinspiration1012.jpg); background-size: 250px; background-repeat: no-repeat; background-position: top center; float: left; color: black; font-weight: bold; font-size: 18px; text-align: center; line-height: 500px; background-color: white; width: 280px; margin-left: 10px; margin-right: 10px; margin-top: 30px; padding: 5px; border: 2px solid black; height: 400px } .box5 { background: url(gymcomedy1012.jpg); background-size: 250px; background-repeat: no-repeat; background-position: top center; float: left; color: black; font-weight: bold; font-size: 18px; text-align: center; line-height: 500px; background-color: white; width: 280px; margin-left: 10px; margin-right: 10px; margin-top: 30px; padding: 5px; border: 2px solid black; height: 400px } .box6 { background: url(instafitnesstransformations2.jpg); background-size: 250px; background-repeat: no-repeat; background-position: top center; float: left; color: black; font-weight: bold; font-size: 18px; text-align: center; line-height: 500px; background-color: white; width: 280px; margin-left: 10px; margin-right: 10px; margin-top: 30px; padding: 5px; border: 2px solid black; height: 400px } .box7 { background: url(motivation2squat2.jpg); background-size: 250px; background-repeat: no-repeat; background-position: top center; float: left; color: black; font-weight: bold; font-size: 18px; text-align: center; line-height: 500px; background-color: white; width: 280px; margin-left: 10px; margin-right: 10px; margin-top: 30px; padding: 5px; border: 2px solid black; height: 400px } .box8 { background: url(fitness_lifestyle202.jpg); background-size: 250px; background-repeat: no-repeat; background-position: top center; float: left; color: black; font-weight: bold; font-size: 18px; text-align: center; line-height: 500px; background-color: white; width: 280px; margin-left: 10px; margin-right: 10px; margin-top: 30px; padding: 5px; border: 2px solid black; height: 400px } .box9 { background: url(gymlife222.jpg); background-size: 250px; background-repeat: no-repeat; background-position: top center; float: left; color: black; font-weight: bold; font-size: 18px; text-align: center; line-height: 500px; background-color: white; width: 280px; margin-left: 10px; margin-right: 10px; margin-top: 30px; padding: 5px; border: 2px solid black; height: 400px .ad-left { float: left; }
 <!DOCTYPE html> <html> <head> <title>Instagram Shoutouts</title> <link rel="stylesheet" href="Instagrampage.css"> </head> <body> <header id="top" class="main-header"> <h1>Instagram Shoutouts</h1> <span class="title">Increase followers with instagram shoutouts!</span> </header> <p>igbodybuildingworld<br>MEDIA FOLLOWERS FOLLOWING<br>101 32K 321<br>Select Options</p> </body> </html> <div class="box"></div> <div class="box2">absmotivation101</div> <div class="box3">instafitnesslifestyle101</div> <div class="box4">absinspiration101</div> <div class="box5">gymcomedy101</div> <div class="box6">instafitnesstransformations</div> <div class="box7">motivation2squat</div> <div class="box8">fitness_lifestyle20</div> <div class="box9">gymlife22</div> </div> </div><!-- End .secondary-content --> <html> <head> </head> <style> .flex-container { display: -webkit-flex; display: flex; width: 280px; height: 400px; background-color: white; border: 0px solid black; } .flex-item { background-color: white; padding-top: 5px; border: 1px solid black; text-align: center; width: 100px; height: 50px; margin:5px; margin-top: 300px; } </style> </head> <body> <div class="flex-container"> <div class="flex-item">MEDIA</div> <div class="flex-item">FOLLOWERS</div> <div class="flex-item">FOLLOWING</div> </div> </body> </html>

我不知道你到底想要什么,但它可能喜欢下面的代码

    <html><head>
    <style>
        /* Base Styles -------------------- */

* { 
box-sizing: border-box;
}
body {
  color: #878787;
  margin: 0;
  font: 1em/1.5 "Helvetica Neue", Helvetica, Arial, sans-serif;
}

h1 {  
  font-size: 5.625rem; /* 90px/16px  */
  font-family: serif;
  color: rgba(255, 255, 255, 1);
  text-transform: uppercase;
  font-weight: bold;
  line-height: 1.3;
}


 img {
  max-width: 100%
    margin-bottom: 20px;
}

/* Pseudo-classes ------------------ */

a:link {
  color: rgb(255, 169, 73);
  text-decoration: none;
}

a:visited {
  color: lightblue;
}

a:hover {
  color: rgba(255, 169, 73, .4);
}

a:active {
  color: lightcoral;
}

.flex-item {
    color: black;
    font-size: 14px;
    font-weight: bold; 
    float: left;
    width: 33.3%;
    text-align: center;
    }
.flex-container {
    width: 100%;
    display: table;
}

/* Main Styles --------------------- */

.main-header {
  background-color: blue;
  padding-top: 20px;
  height: 300px;
  box-sizing: border-box;
}



.title {
  color: white;
  font-size: 1.625rem; /* 26px/16px */
}

.intro {
  font-size: 1.25em; /* 20px/16px */
  line-height: 1.6;  
}

.primary-content,
.main-header,
.main-footer {
  text-align: center;
}

.primary-content {
    padding-top: 25px;
  padding-bottom: 95px;
}

.secondary-content {
    padding-top: 80px;
    padding-bottom: 70px;
  border-bottom: 2px solid #dfe2e6;
}

.callout {
  font-size: 1.25em;
  border-bottom: 3px solid;
  padding: 0 9px 3px;
  margin-top: 20px;
  display: inline-block;
}

.main-footer {
  padding-top: 60px;
  padding-bottom: 60px;
  border-bottom: 10px solid #ffa949;
}

.t-border {
  border-top: 2px solid #dfe2e6;
}

/* Layout Styles ------------------ */



.primary-content, 
.secondary-content {
  width:10%;
  box-sizing: border-;
  padding-left: 10px;
  padding-right: 50px;
  margin: left-side;
  max-width: 50px;
}


.box {

    background: url(igbodybuildingworld2.jpg);
    background-size: 150px;
    background-repeat: no-repeat;
    background-position:  top center;
    float: left;
    color: black;
    font-weight: bold; 
    font-size: 18px;
    text-align: center;
    line-height: 300px;
    background-color: white;
    width: 280px;
    margin-left: 10px;
    margin-right: 10px;
    margin-top: 30px;
    padding: 5px;
    border: 1px solid black;
    height: 400px;



}


.box2 {
    background: url(absmotivation1012.jpg);
    background-size: 250px;
    background-repeat: no-repeat;
    background-position:  top center;
    float: left;
    color: black;
    font-weight: bold;
    font-size: 18px;
    text-align: center;
    line-height: 500px;
    background-color: white;
    width: 280px;
    margin-left: 10px;
    margin-right: 10px;
    margin-top: 30px;
    padding: 5px;
    border: 2px solid black;
    height: 400px
}

.box3 {
    background: url(instafitnesslifestyle1012.jpg);
    background-size: 250px;
    background-repeat: no-repeat;
    background-position:  top center;
    float: left;
    color: black;
    font-weight: bold;
    font-size: 18px;
    text-align: center;
    line-height: 500px;
    background-color: white;
    width: 280px;
    margin-left: 10px;
    margin-right: 10px;
    margin-top: 30px;
    padding: 5px;
    border: 2px solid black;
    height: 400px
}

.box4 {
    background: url(absinspiration1012.jpg);
    background-size: 250px;
    background-repeat: no-repeat;
    background-position:  top center;
    float: left;
    color: black;
    font-weight: bold;
    font-size: 18px;
    text-align: center;
    line-height: 500px;
    background-color: white;
    width: 280px;
    margin-left: 10px;
    margin-right: 10px;
    margin-top: 30px;
    padding: 5px;
    border: 2px solid black;
    height: 400px

}
.box5 {
    background: url(gymcomedy1012.jpg);
    background-size: 250px;
    background-repeat: no-repeat;
    background-position:  top center;
    float: left;
    color: black;
    font-weight: bold;
    font-size: 18px;
    text-align: center;
    line-height: 500px;
    background-color: white;
    width: 280px;
    margin-left: 10px;
    margin-right: 10px;
    margin-top: 30px;
    padding: 5px;
    border: 2px solid black;
    height: 400px
}
.box6 {
    background: url(instafitnesstransformations2.jpg);
    background-size: 250px;
    background-repeat: no-repeat;
    background-position:  top center;
    float: left;
    color: black;
    font-weight: bold;
    font-size: 18px;
    text-align: center;
    line-height: 500px;
    background-color: white;
    width: 280px;
    margin-left: 10px;
    margin-right: 10px;
    margin-top: 30px;
    padding: 5px;
    border: 2px solid black;
    height: 400px
}
.box7 {
    background: url(motivation2squat2.jpg);
    background-size: 250px;
    background-repeat: no-repeat;
    background-position:  top center;
    float: left;
    color: black;
    font-weight: bold;
    font-size: 18px;
    text-align: center;
    line-height: 500px;
    background-color: white;
    width: 280px;
    margin-left: 10px;
    margin-right: 10px;
    margin-top: 30px;
    padding: 5px;
    border: 2px solid black;
    height: 400px
}
.box8 {
    background: url(fitness_lifestyle202.jpg);
    background-size: 250px;
    background-repeat: no-repeat;
    background-position:  top center;
    float: left;
    color: black;
    font-weight: bold;
    font-size: 18px;
    text-align: center;
    line-height: 500px;
    background-color: white;
    width: 280px;
    margin-left: 10px;
    margin-right: 10px;
    margin-top: 30px;
    padding: 5px;
    border: 2px solid black;
    height: 400px
}
    .box9 {
    background: url(gymlife222.jpg);
    background-size: 250px;
    background-repeat: no-repeat;
    background-position:  top center;   
    float: left;
    color: black;
    font-weight: bold;
    font-size: 18px;
    text-align: center;
    line-height: 500px;
    background-color: white;
    width: 280px;
    margin-left: 10px;
    margin-right: 10px;
    margin-top: 30px;
    padding: 5px;
    border: 2px solid black;
    height: 400px

    .ad-left {
  float: left;
}
    </style>
</head>
<body>



    <title>Instagram Shoutouts</title>
    <link rel="stylesheet" href="Instagrampage.css">


    <header id="top" class="main-header">
      <h1>Instagram Shoutouts</h1>
      <span class="title">Increase followers with instagram shoutouts</span>
    </header>

    <p>igbodybuildingworld
       <br>
       MEDIA FOLLOWERS FOLLOWING
       <br>
       101 32K 321
       <br>
       Select Options</p>

        <div class="box"></div>
        <div class="box2">absmotivation101</div>
        <div class="box3">instafitnesslifestyle101</div>
        <div class="box4">absinspiration101</div>
        <div class="box5">gymcomedy101</div>
        <div class="box6">instafitnesstransformations</div>
        <div class="box7">motivation2squat</div>
        <div class="box8">fitness_lifestyle20</div>
        <div class="box9">gymlife22</div>        
       <div class="flex-container">
            <div class="flex-item"><p>12K</p><p>MEDIA</p></div>
            <div class="flex-item"><p>12K</p><p>FOLLOWERS</p></div>
            <div class="flex-item"><p>24K</p><p>FOLLOWING</p></div>
       </div>


    <script type="text/javascript">

    </script>

</body></html>

暂无
暂无

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

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