Bootstrap Css Mobile首次调整大小问题

时间:2016-03-02 00:56:07

标签: html css twitter-bootstrap

在移动设备上运行时无法调整大小。 id中的元素=" mustTake"在移动时相互重叠。我试图在移动设备上实现与顶部两个元素相同的外观。



header {
    background-color: #8FBCDB;
}
.container {
    padding-top: 10px;
}
body {
    background-color: #E0EEEE;
}
#profile {
    position: absolute;
    right: 7%;
    top: 0%;
    z-index: 1;
}
.panel .panel-info {
    position: absolute;
    z-index: 1;
}
.container h1 {
    z-index: 1;
}
.myButton {
    background-color: #44c767;
    -moz-border-radius: 14px;
    -webkit-border-radius: 14px;
    border-radius: 14px;
    border: 1px solid #18ab29;
    display: inline-block;
    cursor: pointer;
    color: #ffffff;
    font-family: Georgia;
    font-size: 14px;
    font-weight: bold;
    padding: 4px 10px;
    text-decoration: none;
    text-shadow: 0px 1px 0px #2f6627;
}
.myButton:hover {
    background-color: #5cbf2a;
}
.myButton:active {
    position: relative;
    top: 1px;
}
.myButton1 {
    background-color: #FFA500;
    -moz-border-radius: 18px;
    -webkit-border-radius: 18px;
    border-radius: 18px;
    border: 1px solid #18ab29;
    display: inline-block;
    cursor: pointer;
    color: #ffffff;
    font-family: Georgia;
    font-size: 19px;
    font-weight: bold;
    padding: 4px 10px;
    text-decoration: none;
    text-shadow: 0px 1px 0px #2f6627;
}
.myButton1:hover {
    background-color: #EE9A00;
}
.myButton1:active {
    position: relative;
    top: 1px;
}
.table-striped tr {
    font-size: 18px;
}
.table-striped th {
    font-size: 20px;
}
.timeline {
    list-style: none;
    padding: 0;
    position: relative
}
.timeline:before {
    top: 0;
    bottom: 0;
    position: absolute;
    content: "";
    width: 2px;
    background-color: #fff;
    left: 40px;
    margin-left: -1.5px
}
.timeline>li {
    margin-bottom: 50px;
    position: relative;
    min-height: 50px
}
.timeline>li:before,
.timeline>li:after {
    content: " ";
    display: table
}
.timeline>li:after {
    clear: both
}
.timeline>li .timeline-panel {
    width: 100%;
    float: right;
    padding: 0 20px 0 100px;
    position: relative;
    text-align: left
}
.timeline>li .timeline-panel:before {
    border-left-width: 0;
    border-right-width: 15px;
    left: -15px;
    right: auto
}
.timeline>li .timeline-panel:after {
    border-left-width: 0;
    border-right-width: 14px;
    left: -14px;
    right: auto
}
.timeline>li .timeline-image {
    left: 0;
    margin-left: 0;
    width: 100px;
    height: 80px;
    position: absolute;
    z-index: 100;
    background-color: ;
    color: #fff;
    border-radius: 5%;
    border: 7px solid #FFCC33;
    text-align: center;
}
timeline>li .timeline-image1 {
    left: 0;
    margin-left: 0;
    width: 100px;
    height: 80px;
    position: absolute;
    z-index: 100;
    background-color: ;
    color: #fff;
    border-radius: 5%;
    border: 7px solid #f1f1f1;
    text-align: center;
}
.timeline>li .timeline-image h4 {
    font-size: 10px;
    margin-top: 12px;
    line-height: 14px;
}
.timeline>li.timeline-inverted>.timeline-panel {
    float: right;
    text-align: left;
    padding: 0 20px 0 100px;
}
.timeline>li.timeline-inverted>.timeline-panel:before {
    border-left-width: 0;
    border-right-width: 15px;
    left: -15px;
    right: auto
}
.timeline>li.timeline-inverted>.timeline-panel:after {
    border-left-width: 0;
    border-right-width: 14px;
    left: -14px;
    right: auto
}
.timeline>li:last-child {
    margin-bottom: 0
}
.timeline .timeline-heading h4 {
    margin-top: 0;
    color: inherit
}
.timeline .timeline-heading h4.subheading {
    text-transform: none
}
.timeline .timeline-body>p,
.timeline .timeline-body>ul {
    margin-bottom: 0
}
.timeline:before {
    left: 50%
}
.timeline>li {
    margin-bottom: 100px;
    min-height: 100px
}
.timeline>li .timeline-panel {
    width: 41%;
    float: left;
    padding: 0 20px 20px 30px;
    text-align: right
}
.timeline>li .timeline-image {
    width: 100px;
    height: 100px;
    left: 50%;
    margin-left: -50px
}
.timeline>li .timeline-image h4 {
    font-size: 13px;
    margin-top: 16px;
    line-height: 18px
}
.timeline>li.timeline-inverted>.timeline-panel {
    float: right;
    text-align: left;
    padding: 0 30px 20px 20px
}
.timeline>li {
    min-height: 170px
}
.timeline>li .timeline-panel {
    padding: 0 20px 20px 100px
}
.timeline>li .timeline-image {
    width: 270px;
    height: 170px;
    margin-left: -133px;
}
.timeline>li .timeline-image h4 {
    margin-top: 40px
}
.timeline>li.timeline-inverted>.timeline-panel {
    padding: 0 100px 20px 20px
}
.timeline>li .timeline-image {
    color: black;
}
.timeline:before {
    background-color: black;
}

<!DOCTYPE html>
<html lang="en">

<head>
  <title>Advising WebApp</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.6/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
  <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>

  <link rel="stylesheet" href="main.css">
</head>

<header>
  <div class="container ">
    <div class="well">
      <div id="profile">
        <b id="welcome"><i><?php echo $login_session; ?></i></b>
        <b id="logout"> <a href="../projectclass/php/logout.php" class="btn btn-lg btn-warning myButton1"><span class="glyphicon glyphicon-log-out"></span> Log-out</a></b>
        <!-- <b id="logout"><a href="../projectclass/php/logout.php">Log Out</a></b> -->
      </div>
      <h1>Advising WebApp</h1>
      <p> Web App that helps with advising of CS majors!</p>
    </div>
  </div>
</header>

<body>

  <div class="container">
    <div class="row">
      <div class="col-lg-12 text-center">
        <hr class="light">
      </div>
    </div>
    <div class="row" id="about-affects">
      <div class="col-lg-12">
        <ul class="timeline">

          <li>
            <div class="timeline-image">
              <h4>CPS210-CompSci-I </h4>
            </div>
          </li>
          <li>
            <div class="timeline-image">
              <h4>CPS310-CompSci-II</h4>
            </div>
          </li>
        </ul>
      </div>
    </div>
  </div>
  <section id="mustTake">
    <div class="container-fluid">
      <div class="row no-gutter">
        <div class="col-lg-12 text-center">
          <h2 class="section-heading">MUST TAKE ALL</h2>
          <hr class="primary">
        </div>
        <div class="col-xs-6 col-md-3">
          <ul class="timeline">

            <li>
              <div class="timeline-image">
                <h4>CPS210-CompSci-I </h4>
              </div>
            </li>
            <li>
              <div class="timeline-image">
                <h4>CPS310-CompSci-II</h4>
              </div>
            </li>
          </ul>

        </div>
        <div class="col-xs-6 col-md-3">
          <ul class="timeline">

            <li>
              <div class="timeline-image">
                <h4>CPS210-CompSci-I </h4>
              </div>
            </li>
            <li>
              <div class="timeline-image">
                <h4>CPS310-CompSci-II</h4>
              </div>
            </li>
          </ul>

        </div>
        <div class="col-xs-6 col-md-3">
          <ul class="timeline">

            <li>
              <div class="timeline-image">
                <h4>CPS210-CompSci-I </h4>
              </div>
            </li>
            <li>
              <div class="timeline-image">
                <h4>CPS310-CompSci-II</h4>
              </div>
            </li>
          </ul>

        </div>
        <div class="col-xs-6 col-md-3">
          <ul class="timeline">

            <li>
              <div class="timeline-image">
                <h4>CPS210-CompSci-I </h4>
              </div>
            </li>
            <li>
              <div class="timeline-image">
                <h4>CPS310-CompSci-II</h4>
              </div>
            </li>
          </ul>

        </div>
      </div>
    </div>
  </section>
  <script src="../projectclass/js/main.js" type="text/javascript"></script>
</body>

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

2 个答案:

答案 0 :(得分:0)

col-xs-* col-md-* col-sm-*的总数必须为每class="row" 12个,除了这个数字。

试试这个:

<section id="mustTake" >
<div class="container-fluid">
    <div class="row no-gutter">
        <div class="col-lg-12 text-center">
            <h2 class="section-heading">MUST TAKE ALL</h2>
            <hr class="primary">
        </div>
    </div>

    <!-- Mobile -->

    <div class="row">
        <div class="col-xs-6 hidden-md hidden-lg">
            <ul class="timeline">
                <li>
                    <div class="timeline-image">
                        <h4>CPS210-CompSci-I </h4>
                    </div>
                </li>
                <li>
                    <div class="timeline-image">
                        <h4>CPS310-CompSci-II</h4>
                    </div>
                </li>
            </ul>
        </div>

        <div class="col-xs-6 hidden-md hidden-lg">
            <ul class="timeline">           
                <li>
                    <div class="timeline-image">
                        <h4>CPS210-CompSci-I </h4>
                    </div>
                </li>
                <li>
                    <div class="timeline-image">
                        <h4>CPS310-CompSci-II</h4>
                    </div>
                </li>
            </ul>
        </div>
    </div>

    <div class="row">
        <div class="col-xs-6 hidden-md hidden-lg">
            <ul class="timeline">
                <li>
                    <div class="timeline-image">
                        <h4>CPS210-CompSci-I </h4>
                    </div>
                </li>
                <li>
                    <div class="timeline-image">
                        <h4>CPS310-CompSci-II</h4>
                    </div>
                </li>
            </ul>
        </div>
        <div class="col-xs-6 hidden-md hidden-lg">
            <ul class="timeline">             
                <li>
                    <div class="timeline-image">
                       <h4>CPS210-CompSci-I </h4>
                     </div>
                </li>
                <li>
                    <div class="timeline-image">
                        <h4>CPS310-CompSci-II</h4>
                    </div>
                </li>
            </ul>
        </div>
    </div>

    <!-- Desktop -->

    <div class="row">
        <div class="col-md-3 hidden-sm hidden-xs">
            <ul class="timeline">
                <li>
                    <div class="timeline-image">
                        <h4>CPS210-CompSci-I </h4>
                    </div>
                </li>
                <li>
                    <div class="timeline-image">
                        <h4>CPS310-CompSci-II</h4>
                    </div>
                </li>
            </ul>
        </div>

        <div class="col-md-3 hidden-sm hidden-xs">
            <ul class="timeline">           
                <li>
                    <div class="timeline-image">
                        <h4>CPS210-CompSci-I </h4>
                    </div>
                </li>
                <li>
                    <div class="timeline-image">
                        <h4>CPS310-CompSci-II</h4>
                    </div>
                </li>
            </ul>
        </div>
        <div class="col-md-3 hidden-sm hidden-xs">
            <ul class="timeline">
                <li>
                    <div class="timeline-image">
                        <h4>CPS210-CompSci-I </h4>
                    </div>
                </li>
                <li>
                    <div class="timeline-image">
                        <h4>CPS310-CompSci-II</h4>
                    </div>
                </li>
            </ul>
        </div>
        <div class="col-md-3 hidden-sm hidden-xs">
            <ul class="timeline">             
                <li>
                    <div class="timeline-image">
                       <h4>CPS210-CompSci-I </h4>
                     </div>
                </li>
                <li>
                    <div class="timeline-image">
                        <h4>CPS310-CompSci-II</h4>
                    </div>
                </li>
            </ul>
        </div>
    </div>
</div>

答案 1 :(得分:0)

在您的Id mustTake中,您已超过每行的cols总数(即12)。对于每个行类,您可以使用12个cols(Bootstrap网格系统):http://www.w3schools.com/bootstrap/bootstrap_grid_basic.asp