在两列Bootstrap中显示文本

时间:2017-12-13 16:18:00

标签: html css twitter-bootstrap

您好我想将从SQL Server检索的文本列(没有问题检索)分发到两列。

jsfiddle

<div class="container-fluid" style="margin-top:170px;">
<div class="row">
    <div class="col-sm-6"><img alt="Bootstrap Image Preview" src="http://placehold.it/300x205/3498db/fff" style="height:320px" class="img-thumbnail"></div>
    <div class="col-lg-6">
        <h1>John Doe</h1>
        <h2><b>Director</b></h2>
        <h5>
            Education, title, 
        </h5>
    </div>
</div>
<div class="row">
    <div class="col-sm-5 col-lg-6">
        <h3 style="margin-top:50px">
            About
        </h3>
        <p class="pp">
            Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris vitae magna arcu. Aenean vulputate neque vitae libero malesuada auctor. Fusce sed congue sem. In ultrices, velit sed aliquam fringilla, massa quam posuere massa, ut viverra quam eros quis purus. Nulla tristique iaculis.
        </p>
        <p> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque auctor malesuada magna, in vulputate nunc eleifend quis. Fusce varius a erat nec faucibus. Aliquam velit ante, fringilla sed sem ac, congue.</p>
        <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed id ipsum vulputate, laoreet metus at, mattis velit. Nullam diam sem, bibendum in odio et, tincidunt fringilla dolor. Etiam sit amet turpis laoreet, rhoncus magna eget, pharetra turpis. Pellentesque ut massa sit amet nibh ultricies efficitur. Proin.</p>
    </div>
    <div class="col-sm-5 col-lg-6" style="margin-top:90px">
        <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec tincidunt laoreet leo non porta. Duis quis blandit lacus. Mauris nec blandit arcu. Sed vulputate condimentum lorem, gravida imperdiet quam efficitur et. Praesent odio odio, convallis fermentum ante sed, semper molestie ipsum. Nulla rutrum tempus nunc quis cursus. Curabitur neque augue, tincidunt eu.<p>
        <p>
           Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut sit amet sem ullamcorper, aliquet ligula non, posuere nunc. Morbi vehicula ac sapien nec vehicula. Donec commodo, elit consequat consectetur suscipit, turpis urna aliquam odio, eget pulvinar ligula.
        </p>
        <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus quis volutpat dui, a mollis lorem. Quisque rutrum in ante id pretium. Curabitur nec turpis lobortis, facilisis..<p>

        

显示所需的布局。如你所见,有段落空格,看起来不错。我只能使用该列获取此far。我无法像上面那样进行格式化。有人可以帮助我获得所需的格式。

3 个答案:

答案 0 :(得分:0)

首先从h3元素中取出.newspaper标题,将其置于该元素之上,以便文本在两列中的同一级别上开始。然后将相应的引导类添加到h3.newspaper DIV以避免负边距并限制较小屏幕上的宽度,如您引用的示例所示:class="col-sm-10 col-lg-12"

结果如下:https://jsfiddle.net/sozeojgx/1/

答案 1 :(得分:0)

您只需2次媒体查询即可实现:

margin

刚刚添加了一个类@media only screen and (max-width: 768px) { .margin { margin-top: 0px; } } @media only screen and (min-width: 769px) { .margin { margin-top: 85px; } }并添加了媒体查询。 选中 CODEPEN

&#13;
&#13;
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<div class="container-fluid" style="margin-top:170px;">
  <div class="row">
    <div class="col-sm-6"><img alt="Bootstrap Image Preview" src="http://placehold.it/300x205/3498db/fff" style="height:320px" class="img-thumbnail"></div>
    <div class="col-lg-6">
      <h1>John Doe</h1>
      <h2><b>Director</b></h2>
      <h5>
        Education, title,
      </h5>
    </div>
    <div class="col-lg-6"></div>
  </div>
  <div class="row">
    <div class="col-sm-5 col-lg-6">
      <h3 style="margin-top:50px">
        About
      </h3>
      <p class="pp">
        Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris vitae magna arcu. Aenean vulputate neque vitae libero malesuada auctor. Fusce sed congue sem. In ultrices, velit sed aliquam fringilla, massa quam posuere massa, ut viverra quam eros quis
        purus. Nulla tristique iaculis.
      </p>
      <p> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque auctor malesuada magna, in vulputate nunc eleifend quis. Fusce varius a erat nec faucibus. Aliquam velit ante, fringilla sed sem ac, congue.</p>
      <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed id ipsum vulputate, laoreet metus at, mattis velit. Nullam diam sem, bibendum in odio et, tincidunt fringilla dolor. Etiam sit amet turpis laoreet, rhoncus magna eget, pharetra turpis.
        Pellentesque ut massa sit amet nibh ultricies efficitur. Proin.</p>
    </div>
    <div class="col-sm-6 col-lg-6 margin">
      <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec tincidunt laoreet leo non porta. Duis quis blandit lacus. Mauris nec blandit arcu. Sed vulputate condimentum lorem, gravida imperdiet quam efficitur et. Praesent odio odio, convallis
        fermentum ante sed, semper molestie ipsum. Nulla rutrum tempus nunc quis cursus. Curabitur neque augue, tincidunt eu.
        <p>
          <p>
            Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut sit amet sem ullamcorper, aliquet ligula n</p>
    </div>
  </div>
</div>
&#13;
package cz.flay.fellcms.http;

import cz.flay.fellcms.dao.UsersRepository;
import cz.flay.fellcms.entities.User;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@CrossOrigin
@RestController
@RequestMapping(path = "/api/users")
public class UsersRestController {

    @Autowired
    private UsersRepository usersRepository;
    Logger logger = LoggerFactory.getLogger(UsersRestController.class);

    @CrossOrigin
    @GetMapping(path = "/all")
    public @ResponseBody Iterable<User> getAll(){
        return usersRepository.findAll();
    }

    @CrossOrigin
    @GetMapping(path = "/verify", params = {"username", "password"})
    public @ResponseBody User verify(@RequestParam(value = "username") String username, @RequestParam(value = "password") String password){
        logger.info("t");
        return usersRepository.verify(username, password);
    }
}
&#13;
&#13;
&#13;

答案 2 :(得分:0)

将div的类更改为 col-xs-6 col-sm-6 col-md-6 col-lg-6

我只对HTML进行了更改,并且工作正常。

<div class="container-fluid" style="margin-top:170px;">
    <div class="row">
        <div class="col-sm-6"><img alt="Bootstrap Image Preview" src="http://placehold.it/300x205/3498db/fff" style="height:320px" class="img-thumbnail"></div>
        <div class="col-xs-6 col-sm-6 col-md-6 col-lg-6">
            <h1>John Doe</h1>
            <h2><b>Director</b></h2>
            <h5>
                Education, title, 
            </h5>
        </div>
    </div>
    <div class="row">
        <div class="col-xs-6 col-sm-6 col-md-6 col-lg-6">
            <h3 style="margin-top:50px">
                About
            </h3>
            <p class="pp">
                Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris vitae magna arcu. Aenean vulputate neque vitae libero malesuada auctor. Fusce sed congue sem. In ultrices, velit sed aliquam fringilla, massa quam posuere massa, ut viverra quam eros quis purus. Nulla tristique iaculis.
            </p>
            <p> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque auctor malesuada magna, in vulputate nunc eleifend quis. Fusce varius a erat nec faucibus. Aliquam velit ante, fringilla sed sem ac, congue.</p>
            <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed id ipsum vulputate, laoreet metus at, mattis velit. Nullam diam sem, bibendum in odio et, tincidunt fringilla dolor. Etiam sit amet turpis laoreet, rhoncus magna eget, pharetra turpis. Pellentesque ut massa sit amet nibh ultricies efficitur. Proin.</p>
        </div>
        <div class="col-sm-5 col-lg-6" style="margin-top:90px">
            <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec tincidunt laoreet leo non porta. Duis quis blandit lacus. Mauris nec blandit arcu. Sed vulputate condimentum lorem, gravida imperdiet quam efficitur et. Praesent odio odio, convallis fermentum ante sed, semper molestie ipsum. Nulla rutrum tempus nunc quis cursus. Curabitur neque augue, tincidunt eu.<p>
            <p>
               Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut sit amet sem ullamcorper, aliquet ligula non, posuere nunc. Morbi vehicula ac sapien nec vehicula. Donec commodo, elit consequat consectetur suscipit, turpis urna aliquam odio, eget pulvinar ligula.
            </p>
            <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus quis volutpat dui, a mollis lorem. Quisque rutrum in ante id pretium. Curabitur nec turpis lobortis, facilisis..<p>
</div>
    </div>    

</div>