带有<ul>和<li>的响应图像幻灯片

时间:2018-07-15 19:55:32

标签: html css bootstrap-4

我有一个图库,其中包含使用<ul><li>以及HTML和一些CSS的幻灯片,但是在移动设备上却没有响应(如您所见here,我正在使用智能手机)。

图库图像会拉远并消失,然后移至下一张图像。

我的问题是:如何使其在手机上响应?

代码:

    .slides {
        padding: 0;
        width: 609px;
        height: 420px;
        display: block;
        margin: 0 auto;
        position: relative;
    }
    
    .slides * {
        user-select: none;
        -ms-user-select: none;
        -moz-user-select: none;
        -khtml-user-select: none;
        -webkit-user-select: none;
        -webkit-touch-callout: none;
    }
    
    .slides input { display: none; }
    
    .slide-container { display: block; }
    
    .slide {
        top: 0;
        opacity: 0;
        width: 609px;
        height: 420px;
        display: block;
        position: absolute;
    
        transform: scale(0);
    
        transition: all .7s ease-in-out;
    }
    
    .slide img {
        width: 100%;
        height: 100%;
    }
    
    .nav label {
        width: 200px;
        height: 100%;
        display: none;
        position: absolute;
    
    	  opacity: 0;
        z-index: 9;
        cursor: pointer;
    
        transition: opacity .2s;
    
        color: #FFF;
        font-size: 156pt;
        text-align: center;
        line-height: 380px;
        font-family: "Varela Round", sans-serif;
        background-color: rgba(255, 255, 255, .3);
        text-shadow: 0px 0px 15px rgb(119, 119, 119);
    }
    
    .slide:hover + .nav label { opacity: 0.5; }
    
    .nav label:hover { opacity: 1; }
    
    .nav .next { right: 0; }
    
    input:checked + .slide-container  .slide {
        opacity: 1;
    
        transform: scale(1);
    
        transition: opacity 1s ease-in-out;
    }
    
    input:checked + .slide-container .nav label { display: block; }
    
    .nav-dots {
    	width: 100%;
    	bottom: 9px;
    	height: 11px;
    	display: block;
    	position: absolute;
    	text-align: center;
    }
    
    .nav-dots .nav-dot {
    	top: -5px;
    	width: 11px;
    	height: 11px;
    	margin: 0 4px;
    	position: relative;
    	border-radius: 100%;
    	display: inline-block;
    	background-color: rgba(0, 0, 0, 0.6);
    }
    
    .nav-dots .nav-dot:hover {
    	cursor: pointer;
    	background-color: rgba(0, 0, 0, 0.8);
    }
    
    input#img-1:checked ~ .nav-dots label#img-dot-1,
    input#img-2:checked ~ .nav-dots label#img-dot-2,
    input#img-3:checked ~ .nav-dots label#img-dot-3,
    input#img-4:checked ~ .nav-dots label#img-dot-4,
    input#img-5:checked ~ .nav-dots label#img-dot-5,
    input#img-6:checked ~ .nav-dots label#img-dot-6,
    input#img-7:checked ~ .nav-dots label#img-dot-7,
    input#img-8:checked ~ .nav-dots label#img-dot-8,
    input#img-9:checked ~ .nav-dots label#img-dot-9,
    input#img-9:checked ~ .nav-dots label#img-dot-10 {
    	background: rgba(0, 0, 0, 0.8);
    }
    <ul class="slides">
      <input type="radio" name="radio-btn" id="img-1" checked />
      <li class="slide-container">
  		<div class="slide">
  			<img src="https://farm1.staticflickr.com/917/42512394395_f66da01120_b.jpg" alt="Foto 1">
          </div>
  		<div class="nav">
  			<label for="img-6" class="prev">&#x2039;</label>
  			<label for="img-2" class="next">&#x203a;</label>
  		</div>
      </li>

      <input type="radio" name="radio-btn" id="img-2" />
      <li class="slide-container">
          <div class="slide">
            <img src="https://farm2.staticflickr.com/1765/41608791950_8df0d62b83_b.jpg">
          </div>
  		<div class="nav">
  			<label for="img-1" class="prev">&#x2039;</label>
  			<label for="img-3" class="next">&#x203a;</label>
  		</div>
      </li>

      <input type="radio" name="radio-btn" id="img-3" />
      <li class="slide-container">
          <div class="slide">
            <img src="https://farm2.staticflickr.com/1767/42512387675_4c7b2ca42a_b.jpg">
          </div>
  		<div class="nav">
  			<label for="img-2" class="prev">&#x2039;</label>
  			<label for="img-4" class="next">&#x203a;</label>
  		</div>
      </li>

      <input type="radio" name="radio-btn" id="img-4" />
      <li class="slide-container">
          <div class="slide">
            <img src="https://farm1.staticflickr.com/845/41608785800_c6d777cfff_b.jpg">
          </div>
  		<div class="nav">
  			<label for="img-3" class="prev">&#x2039;</label>
  			<label for="img-5" class="next">&#x203a;</label>
  		</div>
      </li>

      <input type="radio" name="radio-btn" id="img-5" />
      <li class="slide-container">
          <div class="slide">
            <img src="https://farm2.staticflickr.com/1804/42512382475_6f99d41e5a_b.jpg">
          </div>
  		<div class="nav">
  			<label for="img-4" class="prev">&#x2039;</label>
  			<label for="img-6" class="next">&#x203a;</label>
  		</div>
      </li>

      <input type="radio" name="radio-btn" id="img-6" />
      <li class="slide-container">
          <div class="slide">
            <img src="https://farm2.staticflickr.com/1825/28546926367_cf2647dddf_b.jpg">
          </div>
  		<div class="nav">
  			<label for="img-5" class="prev">&#x2039;</label>
  			<label for="img-7" class="next">&#x203a;</label>
  		</div>
      </li>

      <input type="radio" name="radio-btn" id="img-7" />
      <li class="slide-container">
          <div class="slide">
            <img src="https://farm1.staticflickr.com/921/43369027842_f8d9176a13_b.jpg">
          </div>
  		<div class="nav">
  			<label for="img-6" class="prev">&#x2039;</label>
  			<label for="img-8" class="next">&#x203a;</label>
  		</div>
      </li>

      <input type="radio" name="radio-btn" id="img-8" />
      <li class="slide-container">
          <div class="slide">
            <img src="https://farm1.staticflickr.com/921/42700036144_d33a9f7e6e_b.jpg">
          </div>
      <div class="nav">
        <label for="img-7" class="prev">&#x2039;</label>
        <label for="img-9" class="next">&#x203a;</label>
      </div>
      </li>

      <input type="radio" name="radio-btn" id="img-9" />
      <li class="slide-container">
          <div class="slide">
            <img src="https://farm2.staticflickr.com/1788/43369022132_f60e412b42_b.jpg">
          </div>
  		<div class="nav">
  			<label for="img-8" class="prev">&#x2039;</label>
  			<label for="img-9" class="next">&#x203a;</label>
  		</div>
      </li>

      <input type="radio" name="radio-btn" id="img-10" />
      <li class="slide-container">
          <div class="slide">
            <img src="https://farm1.staticflickr.com/837/29546173958_517b50a57f_b.jpg">
          </div>
      <div class="nav">
        <label for="img-9" class="prev">&#x2039;</label>
        <label for="img-1" class="next">&#x203a;</label>
      </div>
      </li>

      <li class="nav-dots">
        <label for="img-1" class="nav-dot" id="img-dot-1"></label>
        <label for="img-2" class="nav-dot" id="img-dot-2"></label>
        <label for="img-3" class="nav-dot" id="img-dot-3"></label>
        <label for="img-4" class="nav-dot" id="img-dot-4"></label>
        <label for="img-5" class="nav-dot" id="img-dot-5"></label>
        <label for="img-6" class="nav-dot" id="img-dot-6"></label>
        <label for="img-6" class="nav-dot" id="img-dot-7"></label>
        <label for="img-6" class="nav-dot" id="img-dot-8"></label>
        <label for="img-6" class="nav-dot" id="img-dot-9"></label>
        <label for="img-6" class="nav-dot" id="img-dot-10"></label>
      </li>
  </ul>


有人可以帮助我解决这个问题吗?我会很感激的。


(要旨here

2 个答案:

答案 0 :(得分:0)

就我而言,您可以通过在代码中添加以下代码来制作任何图像作为响应:(您甚至不必使用css)

 <img src="example.jpg" style="max-width:100%;width:auto;height:auto;max-height:100%;">

答案 1 :(得分:0)

很抱歉,我以前的答案对您没有帮助,因为我想为您提供帮助,我认为,如果您在开头的代码开头添加此代码,那么我之前允许您使用的代码现在可以正常工作:

<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">