浮动不使用Twitter-Bootstrap

时间:2015-03-30 14:52:44

标签: html css twitter-bootstrap element

我寻找答案,但每当我尝试使用答案时,我仍然没有得到理想的结果。我正在使用bootstrap缩略图元素并尝试让它们在引导程序网站上相互浮动。尝试将它们填入分开的div中。尝试将它们全部放入一个div中。什么都没有用。有任何想法吗?任何意见都将不胜感激。

以下是代码的链接:http://jsbin.com/paregopuni/1/edit?html,css,output



#announcements {
    width: 70%;
    margin-left: auto;
    margin-right: auto;
    margin-top: 3em;
}

.jumbotron p {
    margin: 1em;
}

.jumbotron h1 {
    margin: 0.5em;
}


.floatleft {
    float:  left;
}

.clear {
  clear: both;
}

<!DOCTYPE html>

<html lang="en">
    <head>
        <meta charset="utf-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta name="description" content="portfolio site">

        <!-- Latest compiled and minified CSS -->
        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css">
        <link rel="stylesheet" href="main.css">

        <!--[if lt IE 9]><script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script><![endif]-->

        <title>Sample</title>
    </head>
    <body>
        <div id="wrapper">

            
            <div id="announcements">
            <div class="jumbotron">
                <h1>Announcements</h1>
                <p>...</p>
                <p><a class="btn btn-primary btn-lg" href="#" role="button">Learn more</a></p>
            </div>

                <div class="floatleft">
                    <div class="row">
                    <div class="col-sm-6 col-md-4">
                    <div class="thumbnail">
                        <img src="..." alt="...">
                        <div class="caption">
                            <h3>Thumbnail label</h3>
                            <p>Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ultricies vehicula ut id elit.</p>
                            <p><a href="#" class="btn btn-primary" role="button">Button</a> <a href="#" class="btn btn-default" role="button">Button</a></p>
                        </div>
                    </div>
                </div>
            </div>
                </div>


              
              
                <div class="floatleft">
                    <div class="row">
                    <div class="col-sm-6 col-md-4">
                    <div class="thumbnail">
                        <img src="..." alt="...">
                        <div class="caption">
                            <h3>Thumbnail label</h3>
                            <p>Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ultricies vehicula ut id elit.</p>
                            <p><a href="#" class="btn btn-primary" role="button">Button</a> <a href="#" class="btn btn-default" role="button">Button</a></p>
                        </div>
                    </div>
                </div>
            </div>
                </div>

            </div>
        </div>
    </body>
</html>
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:1)

您的代码无法正常工作,因为您将缩略图放在两个不同的行中,它们必须位于同一个row中。 http://jsbin.com/dekefidawo/1/edit

<div class="row">
  <div class="col-sm-6 col-md-4">
    <div class="thumbnail">
    </div>
  </div>
  <div class="col-sm-6 col-md-4">
    <div class="thumbnail">
    </div>
  </div>
</div>