<ul> <li>1</li> <li>2</li> <li>3</li> <li>4</li> <li>5</li> </ul> ul { border: 5px solid deeppink; overflow: hidden; /* */ } li { border: 1px solid #fff; background: #3CB371; width: 100px; height: 100px; float: left; }
ul { overflow: hidden; /* */ width: 450px; } li { float: left; }
ul { height: 100px; /* */ } li { position: absolute; }
ul { height: 100px; /* */ position: relative; /* , AP */ } li { position: absolute; } li:nth-child(2) { left: 100px; /* + / */ } li:nth-child(3) { left: 200px; /* + / */ } li:nth-child(4) { left: 300px; /* + / */ } li:nth-child(5) { left: 400px; /* + / */ }
ul { height: 100px; /* */ position: relative; /* , AP */ width: 30%; } li { position: absolute; width: 50%; } li:nth-child(2) { left: 50%; /* + / */ } li:nth-child(3) { left: 100%; /* + / */ } li:nth-child(4) { left: 150%; /* + / */ } li:nth-child(5) { left: 200%; /* + / */ } ul { height: 100px; /* */ position: relative; /* , AP */ width: 30%; } li { position: absolute; width: 50%; } li:nth-child(2) { left: 50%; /* + / */ } li:nth-child(3) { left: 100%; /* + / */ } li:nth-child(4) { left: 150%; /* + / */ } li:nth-child(5) { left: 200%; /* + / */ }
ul { height: 100px; /* */ position: relative; /* , AP */ width: 50%; } li { position: absolute; width: 25%; } li:nth-child(2) { left: 25%; /* + / */ } li:nth-child(3) { left: 50%; /* + / */ } li:nth-child(4) { left: 75%; /* + / */ } li:nth-child(5) { left: 100%; /* + / */ }
<ul> <li>1</li><!-- --><li>2</li><!-- --><li>3</li><!-- --><li>4</li><!-- --><li>5</li> </ul>
li { display: inline-block; }
ul { width: 450px; } li { display: inline-block; }
ul { width: 450px; white-space: nowrap; } li { display: inline-block; }
<ul class="example example-10" dir="rtl"> <li>1</li><!-- --><li>2</li><!-- --><li>3</li><!-- --><li>4</li><!-- --><li>5</li> </ul>
ul { width: 100px; white-space: nowrap; } li { display: inline-block; width: 100%; } li:first-child { margin-left: -100%; /* IE */ }
ul { width: 100px; white-space: nowrap; overflow: hidden; } li { display: inline-block; width: 100%; } li:first-child { margin-left: -100%; }
<div> <ul> <li>1</li><!-- --><li>2</li><!-- --><li>3</li><!-- --><li>4</li><!-- --><li>5</li> </ul> </div> div { white-space: nowrap; width: 50%; overflow: hidden; border: 5px solid deeppink; }
ul { border: none; *position: relative; /* oldIE */ *left: -100%; /* oldIE */ transform: translateX(-100%); } /* IE8 */ @media screen\0 { .example-13 { position: relative; left: -100%; } } li { white-space: normal; /* */ display: inline-block; width: 50%; }
div { padding-right: 12%; /* , */ } img { width: 100%; /* , */ vertical-align: bottom; }
<div class="carousel"> <input role="presentation" name="carousel" type="radio" value="1" checked /> <input role="presentation" name="carousel" type="radio" value="2" /> <input role="presentation" name="carousel" type="radio" value="3" /> <input role="presentation" name="carousel" type="radio" value="4" /> <input role="presentation" name="carousel" type="radio" value="5" /> <ul class="carousel-list"> <li><img src="..." alt="Mask #1"></li><!-- --><li><img src="..." alt="Mask #2"></li><!-- --><li><img src="..." alt="Mask #3"></li><!-- --><li><img src="..." alt="Mask #4"></li><!-- --><li><img src="..." alt="Mask #4"></li> </ul> </div> <div class="carousel"> <input role="presentation" name="carousel" type="radio" value="1" checked /> <input role="presentation" name="carousel" type="radio" value="2" /> <input role="presentation" name="carousel" type="radio" value="3" /> <input role="presentation" name="carousel" type="radio" value="4" /> <input role="presentation" name="carousel" type="radio" value="5" /> <ul class="carousel-list"> <li><img src="..." alt="Mask #1"></li><!-- --><li><img src="..." alt="Mask #2"></li><!-- --><li><img src="..." alt="Mask #3"></li><!-- --><li><img src="..." alt="Mask #4"></li><!-- --><li><img src="..." alt="Mask #4"></li> </ul> </div>
.carousel { width: 200px; padding: 5px; overflow: hidden; border: 1px solid #ccc; border-radius: 3px; text-align: center; /* - */ } .carousel-list { white-space: nowrap; padding: 0; margin: 0; transition: transform .3s; } .carousel-list li { white-space: normal; /* */ display: inline-block; width: 100%; } .carousel-list img { width: 100%; /* */ vertical-align: bottom; /* */ } /** * - */ input:nth-child(1):checked ~ ul { transform: translateX(0); } input:nth-child(2):checked ~ ul { transform: translateX(-100%); } input:nth-child(3):checked ~ ul { transform: translateX(-200%); } input:nth-child(4):checked ~ ul { transform: translateX(-300%); } input:nth-child(5):checked ~ ul { transform: translateX(-400%); } /** * */ .carousel-list li { opacity: .1; transition: all .4s; transform: scale(.1); } input:nth-child(1):checked ~ ul li:nth-child(1), input:nth-child(2):checked ~ ul li:nth-child(2), input:nth-child(3):checked ~ ul li:nth-child(3), input:nth-child(4):checked ~ ul li:nth-child(4), input:nth-child(5):checked ~ ul li:nth-child(5) { opacity: 1; transform: scale(1); }
.carousel{width:200px}
.carousel { display: inline-block; width: 200px; padding-right: 190px; /* 10px */ overflow: hidden; border: 1px solid #ccc; border-radius: 3px; text-align: center; /* - */ } .carousel-list { white-space: nowrap; padding: 0; margin: 0; border: none; transition: transform .3s; } .carousel-list li { white-space: normal; /* */ display: inline-block; width: 100%; box-sizing: border-box; padding-right: 10px; /* */ } .carousel-list img { width: 100%; /* */ vertical-align: bottom; } .carousel input { margin-left: -3px; } .carousel input:nth-child(1):checked ~ ul { transform: translateX(0); } .carousel input:nth-child(2):checked ~ ul { transform: translateX(-100%); } .carousel input:nth-child(3):checked ~ ul { transform: translateX(-200%); } .carousel input:nth-child(4):checked ~ ul { transform: translateX(-300%); } .carousel input:nth-child(5):checked ~ ul { transform: translateX(-400%); } .carousel input:nth-child(6):checked ~ ul { transform: translateX(-500%); } .carousel input:nth-child(7):checked ~ ul { transform: translateX(-600%); }
Source: https://habr.com/ru/post/253111/
All Articles