发表于: 2018-11-26 23:04:27

1 791


今天完成的事情:今天主要做的事情就是解决轮播页面的问题。目前的话轮播页面完成度在90%,只剩下一些小的问题需要修改一下。如图所示

<div class="carousel">
   <div class="carousel-inner">
       <input class="carousel-open" type="radio" id="carousel-1" name="carousel" aria-hidden="true" hidden="" checked="checked">
       <div class="carousel-item">

           <img src="./image/1%20下午9.05.02.png">
       </div>
       <input class="carousel-open" type="radio" id="carousel-2" name="carousel" aria-hidden="true" hidden="">
       <div class="carousel-item">
           <img src="./image/2.png">

       </div>
       <input class="carousel-open" type="radio" id="carousel-3" name="carousel" aria-hidden="true" hidden="">
       <div class="carousel-item">
           <img src="./image/3a15425b-c947-4222-8558-0bf01cc36513.png">
       </div>
       <label for="carousel-3" class="carousel-control prev control-1"></label>
       <label for="carousel-2" class="carousel-control next control-1"></label>
       <label for="carousel-1" class="carousel-control prev control-2"></label>
       <label for="carousel-3" class="carousel-control next control-2"></label>
       <label for="carousel-2" class="carousel-control prev control-3"></label>
       <label for="carousel-1" class="carousel-control next control-3"></label>
       <ol class="carousel-indicators">
           <li>
               <label for="carousel-1" class="carousel-bullet"></label>
           </li>
           <li>
               <label for="carousel-2" class="carousel-bullet"></label>
           </li>
           <li>
               <label for="carousel-3" class="carousel-bullet"></label>
           </li>
       </ol>
   </div>
</div>
.carousel {
   position: relative;
}

.carousel-inner {
   position: relative;
   overflow: hidden;
   width: 100%;
}

.carousel-open:checked + .carousel-item {
   position: static;
   opacity: 100;
}

.carousel-item {
   position: absolute;
   opacity: 0;
   -webkit-transition: opacity 0.6s ease-out;
   transition: opacity 0.6s ease-out;
}

.carousel-item img {
   display: block;
   height: auto;
   max-width: 100%;
}

.carousel-control {
   color: #fff;
   cursor: pointer;
   display: none;
   font-size: 40px;
   height: 40px;
   line-height: 35px;
   position: absolute;
   top: 50%;
   -webkit-transform: translate(0, -50%);
   cursor: pointer;
   -ms-transform: translate(0, -50%);
   transform: translate(0, -50%);
   text-align: center;
   width: 40px;
   z-index: 10;
}

.carousel-control.prev {
   left: 2%;
}

.carousel-control.next {
   right: 2%;
}


#carousel-1:checked ~ .control-1,
#carousel-2:checked ~ .control-2,
#carousel-3:checked ~ .control-3 {
   display: block;
}

.carousel-indicators {
   list-style: none;
   margin: 0;
   padding: 0;
   position: absolute;
   bottom: 2%;
   left: 0;
   right: 0;
   text-align: center;
   z-index: 10;
}

.carousel-indicators li {
   display: inline-block;
   margin: 0 5px;
}

.carousel-bullet {
   color: #fff;
   cursor: pointer;
   display: block;
   font-size: 35px;
}

.carousel-bullet:hover {
   color: #aaaaaa;
}

#carousel-1:checked ~ .control-1 ~ .carousel-indicators li:nth-child(1) .carousel-bullet,
#carousel-2:checked ~ .control-2 ~ .carousel-indicators li:nth-child(2) .carousel-bullet,
#carousel-3:checked ~ .control-3 ~ .carousel-indicators li:nth-child(3) .carousel-bullet {
   color: #428bca;
}

#title {
   width: 100%;
   position: absolute;
   padding: 0px;
   margin: 0px auto;
   text-align: center;
   font-size: 27px;
   color: rgba(255, 255, 255, 1);
   font-family: 'Open Sans', sans-serif;
   z-index: 9999;
   text-shadow: 0px 1px 2px rgba(0, 0, 0, 0.33), -1px 0px 2px rgba(255, 255, 255, 0);
}


明天计划的事情: 明天的话计划做完第一个页面吧,上午的话这个页面应该可以修改好
遇到的问题: 

        1,首先遇到的第一个问题是轮播自适应的问题,高度方面的话只能由里面的内容来控制。但是没发设定固定的值,所以这一部分使用padding-bottom来实现来这个效果

       2,第二个问题的话就是左右箭头切换的问题了,刚开始的话简直是一头雾水,完全找不到方法来实现这个效果,自己在网上也查询来相关的网站,这个网站给出的思路是这样的

流程图解释:

(1)把 input[type="radio"] 的一组按钮用设置相同 name 属性的方向进行关联,使得这组 input 可以切换。

(2)用 label 标签可单向绑定 input,点击 label 即可使相应的 input 被:checked。

(3)多个 label 标签可绑定同一个 input,分别为左右切换按钮和底部指示器设置一组 label。

(4)当 input 被:checked 后,通过选择器可控制图片或 label 标签的样式(模拟 JS 的点击事件)。

(5)input:nth-of-type(n)是选择 input 的父元素的第 n 个子元素,也可以给 input 加上 id 来代替。

(6)input ~ 选择 input 之后的兄弟元素(一定是之后,渲染关系不可逆;而且一定是兄弟,如果是子集,请加上后代选择器)。



收获: 这两天主要做的是导航栏和轮播图这个效果,离开了框架的话这两天着实有点吃力的感觉,但是同样的话同于其中一些不经常使用的属性也再次加深了用法。css这一部分这算是马上要做完了,基础方面的自己确实感觉到还有些不是很扎实。这个只能说是以后多写代码吧。总体来说导航栏和轮播图有点时间长了,这两天自己多努力吧


返回列表 返回列表
评论

    分享到