将网页拆分为同一区域内的2列

时间:2016-01-01 14:41:06

标签: html css twitter-bootstrap

我对bootstrap非常新。

这是我的代码。

<!DOCTYPE html>
<html lang="en">
<head>
  <title>Bootstrap Example</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
  <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
</head>
<body>

<nav class="navbar navbar-default">
  <div class="container-fluid">
    <div class="navbar-header">
      <a class="navbar-brand" href="#">TER</a>
    </div>
  </div>
</nav>
<div class="container">
  <h1>Report Dated: 2/1/16</h1>
  <p>This part is inside a .container class.</p> 
  <img src="pics/images.jpg" class="img-circle" alt="Cinque Terre" width="304" height="236">
  <p>The .container class provides a responsive fixed width container.</p>           
</div>

</body>
</html>

我想在图片旁边放置文字。像这样的东西

Picture             Text

我还想增加导航栏高度以包含我的徽标。

我该如何做到这一点。

很抱歉,因为我不知道谷歌的用途。

2 个答案:

答案 0 :(得分:2)

如果要在旁边显示图片和文本。然后您可以按照引导网格结构进行操作 http://getbootstrap.com/css/#grid

上述问题的示例:

<div class="row">
<div class="col-sm-6 col-md-6 col-xs-6">
  <img src="pics/images.jpg" class="img-circle " alt="Cinque Terre" width="304" height="236"></div>
  <div class="col-sm-6 col-md-6 col-xs-6"><p>The .container class provides a responsive fixed width container.</p> </div> </div>         
</div>

答案 1 :(得分:1)

使用css

拿这个

  <img src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQMQ6edupFreoXZgXczTGBGeR4EEVKx1x7KnEzbkzC6XXMzeDhZTA" class="img-circle" alt="Cinque Terre" width="304" height="236">
  <p >The .container class provides a responsive fixed width container.</p>         

并将其放入一个id='flex'的div容器中,如下所示

 <div id='flex'>
  <img src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQMQ6edupFreoXZgXczTGBGeR4EEVKx1x7KnEzbkzC6XXMzeDhZTA" class="img-circle" alt="Cinque Terre" width="304" height="236">
  <span >The .container class provides a responsive fixed width container.</span>         
  </div>

使用css的样式

#flex{
  display:flex;
}

#flex{
  display:flex;
}
  <title>Bootstrap Example</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
  <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
</head>
<body>

<nav class="navbar navbar-default">
  <div class="container-fluid">
    <div class="navbar-header">
      <a class="navbar-brand" href="#">TER</a>
    </div>
  </div>
</nav>
<div class="container">
  <h1>Report Dated: 2/1/16</h1>
  <p>This part is inside a .container class.</p> 
  <div id='flex'>
  <img src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQMQ6edupFreoXZgXczTGBGeR4EEVKx1x7KnEzbkzC6XXMzeDhZTA" class="img-circle" alt="Cinque Terre" width="304" height="236">
  <p >The .container class provides a responsive fixed width container.</p>         
  </div>
</div>

</bo id=''dy>
</html>