html - 要成为内联 block 的部分

标签 html css

我有 section 标签,其中有 4 列,我希望我的列是行内 block ,我正在尝试但没有正确完成。我专栏的标题是

  • 最多 365 天/年
  • 秒送达
  • 100% 原创
  • 订购任何东西。
    我希望这些是内联 block 或网格形式。请告诉我我做错了什么。

/*     
    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>

最佳答案

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

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

/*     
    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%;
}
<!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>

关于html - 要成为内联 block 的部分,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33402540/

相关文章:

php - 从数据库中获取同一事物的多行

javascript - 当选择元素被下拉时是否触发事件

html - 如何删除工具提示但保留 'title' 属性值

html - 使用 CSS/CSS3 自动调整所有元素的高度(使高度相等)

html - 将两张图片与下面的文字叠加

javascript - 如何在 MVC 中实现 <ul> nav-tabs 使其表现得像 <a data-toggle ="tab"href ="#">?

javascript - 如何使用 CSS 创建一个三 Angular 形 div,它在单击时会消失,但在单击 'overflow' 部分时不会消失?

php - Wordpress 发布缩略图问题

css - 如何使用一个命令选择所有标题?

html - 如何在 html 元素之间创建一致的间距?