部分为内联块

时间:2015-10-28 22:15:15

标签: html css

我有section标签,其中我有4列,我希望我的列是内联块,我正在尝试但是没有正确地执行它。我的专栏标题是

  • 最多365天/年
  • 以秒为单位递送
  • 100%Orignal
  • 订购任何东西。
    我希望这些是内联块或网格形式。请告诉我我做错了什么。

/*     
    color:     #2ecc71
*/
/* -------------------------- Basic Setup ----------------------------------*/
*{
    mar/*     
    color:         gin: 0;
*/    padding: 0;
    box-sizing: border-box;
}

html{
    background-color: #fff;
    color: #555;
    font-family: 'Lato','Arial',sans-serif;
    font-weight: 300px;
    font-size: 20px;
    text-rendering: optimizeLegibility;
}

/* -------------------------- Reusable Component ----------------------------------*/
.row{
    max-width: 1140px;
    margin: 0 auto;
}

section{
    padding: 80px 0;
}

h1,
h2,
h3{
    
    font-weight: 300;
    text-transform: uppercase;
    
    
}

h1{
    margin: 0;
    margin-bottom: 20px;
    color: #fff;
    font-size: 240%;
    word-spacing: 4px;
    letter-spacing: 1px;
}

h2{
    font-size: 180%;
    word-spacing: 2px;
    text-align: center;
    margin-bottom: 30px;
}

h2:after{
    display: block;
    height: 2px;
    background-color: #2ecc71;
    content: " ";
    width: 100px;
    margin: 0 auto;
    margin-top: 30px;
    letter-spacing: 1px;
}

h3{
    font-size: 110%;
    margin-bottom: 15px;
}

.box{
    padding: 1%; 
}
/* --------Paragraphs----------- */

.long-copy{
    line-height: 145%;
    width: 70%;
    margin-left: 15%;
}
.box p{
    font-size: 90%;
    line-height: 145%;
}

/* --------ICONS----------- */

.icon-big{
    font-size: 350%;
    display: block;
    color:#2ecc71;
    margin-bottom: 10px;
}
/*-------------------- Buttons -------------------*/
.btn:link,
.btn:visited{
    display: inline-block;
    padding: 10px 30px;
    font-weight: 300;
    text-decoration: none;
    border-radius: 200px;
    color: #fff;
    transition: background-color 0.2s, border 0.2s, color 0.2s;
}

.btn-full:link,
.btn-full:visited{
    background-color: #2ecc71;
    border: 1px solid #2ecc71;
    color: #fff;
    margin-right: 15px;
}

.btn-ghost:link,
.btn-ghost:visited{
    border: 1px solid #2ecc71;
    color: #2ecc71;
}

.btn:hover,
.btn:active{
    background-color: #1e874b;
}

.btn-full:hover,
.btn-full:active{
    border: 1px solid #1e874b;
}

.btn-ghost:hover,
.btn-ghost:active{
    border: 1px solid #1e874b;
    color: #fff;
}

/* -------------------------- Heaader ----------------------------------*/
header{
    background-image:linear-gradient(rgba(0, 0, 0, 0.8),rgba(0, 0, 0, 0.8)),url(img/hero.jpg);
    background-size: cover;
    background-position: center;
    height: 100vh;
}

.hero-text-box{
    position: absolute;
    width: 1140px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align:right;
}

.logo{
    
    height: 100px;
    width: auto;
    float: left;
    margin-top: 20px;
}

.main-nav{
    float: right;
    list-style: none;
    margin-top: 55px;
}

.main-nav li{
    display: inline-block;
    margin-left: 40px;
}

.main-nav li a:link,
.main-nav li a:visited{
    padding: 8px 0;
    color: #fff;
    text-decoration: none;
    text-transform: uppercase;
    font-size: 90%;
    border-bottom: 2px solid transparent;
    transition: border-bottom 0.2s;
}

.main-nav li a:hover,
.main-nav li a:active{
    border-bottom: 2px solid #2ecc71;
}
<!DOCTYPE html>
<html lang="en">
    <head>
        <link rel="stylesheet" type="text/css" href="vendors/css/normalize.css">
        <link rel="stylesheet" type="text/css" href="vendors/css/grid.css">
        <link rel="stylesheet" type="text/css" href="resources/css/style.css">
        <link rel="stylesheet" type="text/css" href="vendors/css/ionicons.min.css">
        <link href='https://fonts.googleapis.com/css?family=Lato:400,100,300,300italic' rel='stylesheet' type='text/css'>
        <title>Musica</title>
    </head>
    <body>
        <header>
            <nav>
                <div class="row">
                    <img src="resources/img/logo--color.png" alt="Musica logo" class="logo">
                    <ul class="main-nav">
                        <li><a href="#">Music Delievery</a></li>
                        <li><a href="#">How it works</a></li>
                        <li><a href="#">Our Clients</a></li>
                        <li><a href="#">Sign up</a></li>
                    </ul>
                </div>
            </nav>
            <div class="hero-text-box">
                <h1>Life is the Song.<br> Love is the Music.</h1>
                <a class="btn btn-full" href="#">Listen </a>
                <a class="btn btn-ghost" href="#">Show me more</a>
            </div>
        </header>
        
        <section class="section-features">
            <div class="row">
                <h2>Get Your Music</h2>
                <p class="long-copy">
                    Hello, we're Musica, your premium music delivery service. We know you care for Music. So let us make you relax, we're really good at it, we promise!
                </p>
            </div>
            
            <div class="row">
                <div class="col span-1-of-4 box">
                    <i class="ion-ios-infinite-outline icon-big"></i>
                    <h3>Up to 365 days/year</h3>
                    <p>
                    We really mean that. Our subscrition plan include up to 365 days/year coverage. You can also choose to order more flexibly if that's your style.
                    </p>
                </div>
                <div class="col span-1-of-4 box">
                    <i class="ion-ios-stopwatch-outline icon-big"></i>
                    <h3>Delivered witin seconds</h3>
                    <p>
                    Your are only seconds away from Music. We work with the best music directors in each town to ensure that you're 100% happy.
                    </p>
                </div>
                <div class="col span-1-of-4 box">
                    <i class="ion-ios-play-outline icon-big"></i>
                    <h3>100% Orignal</h3>
                    <p>
                     All our music is orignal and produced by Musica. We take responsibility if it has been pirated.
                    </p>
                </div>
                <div class="col span-1-of-4 box">
                    <i class="ion-ios-cart-outline icon-big"></i>
                    <h3>Order anything</h3>
                    <p>
                    We don't limit your creativity, which means you can order wahtever you feel like. You can also choose from our catalougue containing over 20 genres. It's up to you!
                    </p>
                </div>
            </div>
        </section>
    </body>
</html>

1 个答案:

答案 0 :(得分:1)

为什么不使用float:left?另外,不要忘记设置宽度。请注意,我更改的课程是.span-1-of-4

我可能还建议您尝试使用自举网格系统,以确保您的网页与不同的屏幕尺寸更兼容!见http://getbootstrap.com/css/#grid

&#13;
&#13;
/*     
    color:     #2ecc71
*/
/* -------------------------- Basic Setup ----------------------------------*/
*{
    mar/*     
    color:         gin: 0;
*/    padding: 0;
    box-sizing: border-box;
}

html{
    background-color: #fff;
    color: #555;
    font-family: 'Lato','Arial',sans-serif;
    font-weight: 300px;
    font-size: 20px;
    text-rendering: optimizeLegibility;
}

/* -------------------------- Reusable Component ----------------------------------*/
.row{
    max-width: 1140px;
    margin: 0 auto;
}

section{
    padding: 80px 0;
}

h1,
h2,
h3{
    
    font-weight: 300;
    text-transform: uppercase;
    
    
}

h1{
    margin: 0;
    margin-bottom: 20px;
    color: #fff;
    font-size: 240%;
    word-spacing: 4px;
    letter-spacing: 1px;
}

h2{
    font-size: 180%;
    word-spacing: 2px;
    text-align: center;
    margin-bottom: 30px;
}

h2:after{
    display: block;
    height: 2px;
    background-color: #2ecc71;
    content: " ";
    width: 100px;
    margin: 0 auto;
    margin-top: 30px;
    letter-spacing: 1px;
}

h3{
    font-size: 110%;
    margin-bottom: 15px;
}

.box{
    padding: 1%; 
}
/* --------Paragraphs----------- */

.long-copy{
    line-height: 145%;
    width: 70%;
    margin-left: 15%;
}
.box p{
    font-size: 90%;
    line-height: 145%;
}

/* --------ICONS----------- */

.icon-big{
    font-size: 350%;
    display: block;
    color:#2ecc71;
    margin-bottom: 10px;
}
/*-------------------- Buttons -------------------*/
.btn:link,
.btn:visited{
    display: inline-block;
    padding: 10px 30px;
    font-weight: 300;
    text-decoration: none;
    border-radius: 200px;
    color: #fff;
    transition: background-color 0.2s, border 0.2s, color 0.2s;
}

.btn-full:link,
.btn-full:visited{
    background-color: #2ecc71;
    border: 1px solid #2ecc71;
    color: #fff;
    margin-right: 15px;
}

.btn-ghost:link,
.btn-ghost:visited{
    border: 1px solid #2ecc71;
    color: #2ecc71;
}

.btn:hover,
.btn:active{
    background-color: #1e874b;
}

.btn-full:hover,
.btn-full:active{
    border: 1px solid #1e874b;
}

.btn-ghost:hover,
.btn-ghost:active{
    border: 1px solid #1e874b;
    color: #fff;
}

/* -------------------------- Heaader ----------------------------------*/
header{
    background-image:linear-gradient(rgba(0, 0, 0, 0.8),rgba(0, 0, 0, 0.8)),url(img/hero.jpg);
    background-size: cover;
    background-position: center;
    height: 100vh;
}

.hero-text-box{
    position: absolute;
    width: 1140px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align:right;
}

.logo{
    
    height: 100px;
    width: auto;
    float: left;
    margin-top: 20px;
}

.main-nav{
    float: right;
    list-style: none;
    margin-top: 55px;
}

.main-nav li{
    display: inline-block;
    margin-left: 40px;
}

.main-nav li a:link,
.main-nav li a:visited{
    padding: 8px 0;
    color: #fff;
    text-decoration: none;
    text-transform: uppercase;
    font-size: 90%;
    border-bottom: 2px solid transparent;
    transition: border-bottom 0.2s;
}

.main-nav li a:hover,
.main-nav li a:active{
    border-bottom: 2px solid #2ecc71;
}

.span-1-of-4 {
    float:left;
    width:25%;
}
&#13;
<!DOCTYPE html>
<html lang="en">
    <head>
        <link rel="stylesheet" type="text/css" href="vendors/css/normalize.css">
        <link rel="stylesheet" type="text/css" href="vendors/css/grid.css">
        <link rel="stylesheet" type="text/css" href="resources/css/style.css">
        <link rel="stylesheet" type="text/css" href="vendors/css/ionicons.min.css">
        <link href='https://fonts.googleapis.com/css?family=Lato:400,100,300,300italic' rel='stylesheet' type='text/css'>
        <title>Musica</title>
    </head>
    <body>
        <header>
            <nav>
                <div class="row">
                    <img src="resources/img/logo--color.png" alt="Musica logo" class="logo">
                    <ul class="main-nav">
                        <li><a href="#">Music Delievery</a></li>
                        <li><a href="#">How it works</a></li>
                        <li><a href="#">Our Clients</a></li>
                        <li><a href="#">Sign up</a></li>
                    </ul>
                </div>
            </nav>
            <div class="hero-text-box">
                <h1>Life is the Song.<br> Love is the Music.</h1>
                <a class="btn btn-full" href="#">Listen </a>
                <a class="btn btn-ghost" href="#">Show me more</a>
            </div>
        </header>
        
        <section class="section-features">
            <div class="row">
                <h2>Get Your Music</h2>
                <p class="long-copy">
                    Hello, we're Musica, your premium music delivery service. We know you care for Music. So let us make you relax, we're really good at it, we promise!
                </p>
            </div>
            
            <div class="row">
                <div class="col span-1-of-4 box">
                    <i class="ion-ios-infinite-outline icon-big"></i>
                    <h3>Up to 365 days/year</h3>
                    <p>
                    We really mean that. Our subscrition plan include up to 365 days/year coverage. You can also choose to order more flexibly if that's your style.
                    </p>
                </div>
                <div class="col span-1-of-4 box">
                    <i class="ion-ios-stopwatch-outline icon-big"></i>
                    <h3>Delivered witin seconds</h3>
                    <p>
                    Your are only seconds away from Music. We work with the best music directors in each town to ensure that you're 100% happy.
                    </p>
                </div>
                <div class="col span-1-of-4 box">
                    <i class="ion-ios-play-outline icon-big"></i>
                    <h3>100% Orignal</h3>
                    <p>
                     All our music is orignal and produced by Musica. We take responsibility if it has been pirated.
                    </p>
                </div>
                <div class="col span-1-of-4 box">
                    <i class="ion-ios-cart-outline icon-big"></i>
                    <h3>Order anything</h3>
                    <p>
                    We don't limit your creativity, which means you can order wahtever you feel like. You can also choose from our catalougue containing over 20 genres. It's up to you!
                    </p>
                </div>
            </div>
        </section>
    </body>
</html>
&#13;
&#13;
&#13;