较小屏幕右侧出现空白的滑块

时间:2015-07-20 08:54:46

标签: css3 slider whitespace

我使用滑块和随附的CSS。



.slider {
  position: relative;
  background: #f6f7f9;
  margin-bottom: 50px;
}
.slider .slides {
  list-style: none;
  margin: 0;
  padding: 0;
  *zoom: 1;
}
.slider .slides:after {
  content: " ";
  clear: both;
  display: block;
  overflow: hidden;
  height: 0;
}
.slider .slides li {
  float: left;
  width: 100%;
 margin-right: -100%;
  padding: 30px 0;
}
.slider .slides li img {
  float: right;
}
.slider .slide-caption {
  padding: 70px 50px 30px 0;
}
.slider .slide-title, .slider .slide-subtitle, .slider .slide-summary, .slider .button {
  -webkit-transition: .3s ease-in;
          transition: .3s ease-in;
  opacity: 0;
}
.slider .slide-title {
  color: #152559;
  margin: 0 0 10px;
  font-size: 55px;
  font-size: 2.8375em;
  -webkit-transform: scale(1.5);
      -ms-transform: scale(1.5);
          transform: scale(1.5);
  line-height: 55px;
}
.slider .slide-subtitle {
  color: #01a6d4;
  display: block;
  margin: 0 0 50px;
  font-weight: 300;
  font-size: 36px;
  font-size: 2.25em;
  -webkit-transform: scale(1.5);
      -ms-transform: scale(1.5);
          transform: scale(1.5);
  -webkit-transition-delay: .3s;
          transition-delay: .3s;
}
.slider .slide-summary {
  -webkit-transform: translateX(200px);
      -ms-transform: translateX(200px);
          transform: translateX(200px);
  -webkit-transition-delay: .6s;
          transition-delay: .6s;
  margin-bottom: 50px;
}
.slider .button {
  -webkit-transform: scale(0.3);
      -ms-transform: scale(0.3);
          transform: scale(0.3);
  -webkit-transition-delay: .9s;
          transition-delay: .9s;
}
.slider .flex-active-slide .slide-title, .slider .flex-active-slide .slide-subtitle {
  -webkit-transform: scale(1);
      -ms-transform: scale(1);
          transform: scale(1);
  opacity: 1;
}
.slider .flex-active-slide .slide-summary {
  -webkit-transform: translateX(0);
      -ms-transform: translateX(0);
          transform: translateX(0);
  opacity: 1;
}
.slider .flex-active-slide .button {
  -webkit-transform: scale(1);
      -ms-transform: scale(1);
          transform: scale(1);
  opacity: 1;
}
.slider .flex-control-nav {
  list-style: none;
  text-align: center;
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  z-index: 9;
}
.slider .flex-control-nav li {
  display: inline-block;
  margin: 0 2px;
}
.slider .flex-control-nav li a {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #cbccce;
  display: block;
  text-indent: -9999px;
  cursor: pointer;
}
.slider .flex-control-nav li a.flex-active {
  background: #01a6d4;
}

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<body>
      <div class="slider">
          <ul class="slides">
            <li>
              <div class="container">
                 
                <div class="slide-caption">
                  <h2 class="slide-title">Welcome </h2>
                  <small class="slide-subtitle">Start Your Own blah blah blah</small>
                  <div class="slide-summary">
                    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Necessitatibus, illum laborum odit est quibusdam, molestias quaerat qui, eveniet voluptate debitis, earum dolorem. Fuga maxime fugit excepturi, saepe fugiat quisquam quia!
                    </p>
                  </div>
                  <a href="" class="button">Read More</a>
                </div>
              </div>
            </li>
            <li>
                
                <div class="slide-caption">
                  <h2 class="slide-title">Blah blah blah blah</h2>
                  <small class="slide-subtitle">Blah blah blah blah</small>
                  <div class="slide-summary">
                    <p>Perspiciatis quo, aspernatur similique? Cumque quidem ipsa et. Nobis officia error nam veritatis culpa ut ullam maxime in ad hic, earum repudiandae?
                    </p>
                  </div>
                  
                </div>
              
            </li>
            <li>
                 
                <div class="slide-caption">
                  <h2 class="slide-title">Easy to Use blah blah blah</h2>
                  <small class="slide-subtitle">manage blah blah blah blah blah</small>
                  <div class="slide-summary">
                    <p>Sapiente porro, laudantium consectetur doloremque. Explicabo, esse, expedita. Animi dolorum aliquid nihil necessitatibus itaque quis architecto, fuga rerum.
                    </p>
                  </div>
                  
                </div>
              
            </li>
          </ul> <!-- .slides -->
        </div> <!-- .slider -->
</body>
&#13;
&#13;
&#13;

我正在使用滑块有效的完整版本的javascript版本但保持简单,因为边距问题似乎源于css。 任何想法为什么我在灰色区域的右侧获得一个空格以及如何删除它?它不会出现在更大的屏幕上。

1 个答案:

答案 0 :(得分:1)

&#13;
&#13;
.slider {
  position: relative;
  background: #f6f7f9;
  margin-bottom: 50px;
}
.slider .slides {
  list-style: none;
  margin: 0;
  padding: 0;
  *zoom: 1;
}
.slider .slides:after {
  content: " ";
  clear: both;
  display: block;
  overflow: hidden;
  height: 0;
}
.slider .slides li {
  float: left;
  width: 100%;
 margin-right: -100%;
  padding: 30px 0;
}
.slider .slides li img {
  float: right;
}
.slider .slide-caption {
  padding: 70px 250px 30px 0;
}
.slider .slide-title, .slider .slide-subtitle, .slider .slide-summary, .slider .button {
  -webkit-transition: .3s ease-in;
          transition: .3s ease-in;
  opacity: 0;
}
.slider .slide-title {
  color: #152559;
  margin: 0 0 10px;
  font-size: 55px;
  font-size: 2.8375em;
  -webkit-transform: scale(1.5);
      -ms-transform: scale(1.5);
          transform: scale(1.5);
  line-height: 55px;
}
.slider .slide-subtitle {
  color: #01a6d4;
  display: block;
  margin: 0 0 50px;
  font-weight: 300;
  font-size: 36px;
  font-size: 2.25em;
  -webkit-transform: scale(1.5);
      -ms-transform: scale(1.5);
          transform: scale(1.5);
  -webkit-transition-delay: .3s;
          transition-delay: .3s;
}
.slider .slide-summary {
  -webkit-transform: translateX(200px);
      -ms-transform: translateX(200px);
          transform: translateX(200px);
  -webkit-transition-delay: .6s;
          transition-delay: .6s;
  margin-bottom: 50px;
}
.slider .button {
  -webkit-transform: scale(0.3);
      -ms-transform: scale(0.3);
          transform: scale(0.3);
  -webkit-transition-delay: .9s;
          transition-delay: .9s;
}
.slider .flex-active-slide .slide-title, .slider .flex-active-slide .slide-subtitle {
  -webkit-transform: scale(1);
      -ms-transform: scale(1);
          transform: scale(1);
  opacity: 1;
}
.slider .flex-active-slide .slide-summary {
  -webkit-transform: translateX(0);
      -ms-transform: translateX(0);
          transform: translateX(0);
  opacity: 1;
}
.slider .flex-active-slide .button {
  -webkit-transform: scale(1);
      -ms-transform: scale(1);
          transform: scale(1);
  opacity: 1;
}
.slider .flex-control-nav {
  list-style: none;
  text-align: center;
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  z-index: 9;
}
.slider .flex-control-nav li {
  display: inline-block;
  margin: 0 2px;
}
.slider .flex-control-nav li a {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #cbccce;
  display: block;
  text-indent: -9999px;
  cursor: pointer;
}
.slider .flex-control-nav li a.flex-active {
  background: #01a6d4;
}
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<body>
      <div class="slider">
          <ul class="slides">
            <li>
              <div class="container">
                 
                <div class="slide-caption">
                  <h2 class="slide-title">Welcome </h2>
                  <small class="slide-subtitle">Start Your Own blah blah blah</small>
                  <div class="slide-summary">
                    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Necessitatibus, illum laborum odit est quibusdam, molestias quaerat qui, eveniet voluptate debitis, earum dolorem. Fuga maxime fugit excepturi, saepe fugiat quisquam quia!
                    </p>
                  </div>
                  <a href="" class="button">Read More</a>
                </div>
              </div>
            </li>
            <li>
                
                <div class="slide-caption">
                  <h2 class="slide-title">Blah blah blah blah</h2>
                  <small class="slide-subtitle">Blah blah blah blah</small>
                  <div class="slide-summary">
                    <p>Perspiciatis quo, aspernatur similique? Cumque quidem ipsa et. Nobis officia error nam veritatis culpa ut ullam maxime in ad hic, earum repudiandae?
                    </p>
                  </div>
                  
                </div>
              
            </li>
            <li>
                 
                <div class="slide-caption">
                  <h2 class="slide-title">Easy to Use blah blah blah</h2>
                  <small class="slide-subtitle">manage blah blah blah blah blah</small>
                  <div class="slide-summary">
                    <p>Sapiente porro, laudantium consectetur doloremque. Explicabo, esse, expedita. Animi dolorum aliquid nihil necessitatibus itaque quis architecto, fuga rerum.
                    </p>
                  </div>
                  
                </div>
              
            </li>
          </ul> <!-- .slides -->
        </div> <!-- .slider -->
</body>
&#13;
&#13;
&#13;