国产成人精品亚洲777人妖,欧美日韩精品一区视频,最新亚洲国产,国产乱码精品一区二区亚洲

您的位置:首頁技術文章
文章詳情頁

javascript - css輪播圖適應布局問題

瀏覽:126日期:2022-11-20 17:00:20

問題描述

javascript - css輪播圖適應布局問題

類似于輪播圖布局,外面藍色容器不設置寬度,100%自適應,而每一個子容器的寬度等于父容器的寬度并且一排顯示,父元素超出的部分進行隱藏,在不使用js的情況下能實現嗎?

問題解答

回答1:

純靠CSS就可以實現類似效果:

HTML:<body style=’margin: 0;’> <p style=’position: absolute;width: 40%;height: 100%;background-color: blue;overflow: hidden;’><p style=’position: absolute;width: 100%;height: 80%;background-color: orange;top: 10%;left: 200%;’></p><p style=’position: absolute;width: 100%;height: 80%;background-color: green;top: 10%;left: 200%;’></p><p style=’position: absolute;width: 100%;height: 80%;background-color: red;top: 10%;left: 200%;’></p> </p></body>

CSS:.p1{ animation: pleft 6s infinite linear; -webkit-animation: pleft 6s infinite linear; animation-fill-mode: both; -webkit-animation-fill-mode: both;}@keyframes pleft{ 0%{left: 200%} 100%{left: -100%}}.p2{ animation: pmid 6s infinite linear; -webkit-animation: pmid 6s infinite linear; animation-fill-mode: both; -webkit-animation-fill-mode: both; animation-delay:2s; -webkit-animation-delay:2s;}@keyframes pmid{ 0%{left: 200%} 100%{left: -100%}}.p3{ animation: pright 6s infinite linear; -webkit-animation: pright 6s infinite linear; animation-fill-mode: both; -webkit-animation-fill-mode: both; animation-delay:4s; -webkit-animation-delay:4s;}@keyframes pright{ 0%{left: 200%} 100%{left: -100%}}

jsfiddle.net看看是不是你想要的

回答2:

想了兩種方法: flex 與 inline-block容器設了寬度是為了便于觀察.按理來說用定位也是可以的.但是得一個一個設置定位, 就沒弄了.

https://jsfiddle.net/m41tLwqb/1/https://jsfiddle.net/2zcqqj26/

回答3:

曾用純CSS做輪播,至于你說的這個,應該能實現,但自己沒做過,沒法肯定

標簽: JavaScript
相關文章:
主站蜘蛛池模板: 富民县| 洛阳市| 南投市| 梓潼县| 彭泽县| 宁国市| 邹平县| 泗洪县| 汕头市| 葵青区| 二连浩特市| 老河口市| 安庆市| 饶河县| 海南省| 根河市| 缙云县| 阿拉善左旗| 松潘县| 孝感市| 隆化县| 宜丰县| 彭泽县| 江山市| 昌乐县| 石渠县| 鹤壁市| 山东省| 安仁县| 平乐县| 嘉黎县| 开封市| 什邡市| 历史| 北安市| 河源市| 两当县| 邯郸县| 湘乡市| 永仁县| 延川县|