I just created a image slider and when I opened the slider in chrome and safari the 3 navigation buttons on the bottom of the slider didn't show up. Here is the code http://cssdeck.com/labs/full/ivxl7z5k
EDIT: slider works in all browsers now, but the red bar on top of the slider is still there. If anyone could tell me what I need to edit in the code to remove the gap i would appreciate it
HTML code:
<div id="slides">
<input checked type="radio" name="slider" id="slide1" class="set" />
<input type="radio" name="slider" id="slide2" class="set" />
<input type="radio" name="slider" id="slide3" class="set" />
<div class="mask">
<div class="overflow">
<div class="slide">
<img src="images/slideshow1.jpg">
</div>
<div class="slide">
<img src="images/slideshow2.jpg">
</div>
<div class="slide">
<img src="images/slideshow3.jpg">
</div>
</div>
</div>
<div id="controls" onclick="">
<label for="slide1"></label>
<label for="slide2"></label>
<label for="slide3"></label>
</div>
</div>
CSS code:
#slides {
position:absolute;
width:1024px;
height: 525px;
margin: 0;
padding: 0;
left: 256px;
background: #ddd;
}
#slides input {
position: relative;
left: 30px;
top: 500px;
}
#slides .mask {
width:1024px;
overflow:hidden;
margin:auto;
}
#slides .overflow {
width:400%;
-webkit-transform:translateZ(0);
-webkit-transition:all 0.5s ease-out;
-moz-transition:all 0.5s ease-out;
-o-transition:all 0.5s ease-out;
transition:all 0.5s ease-out;
}
#slides .slide {
width: 1024px;
height: 525px;
float:left;
background:#fff;
#controls { width:100%; }
#controls label {
display:none;
width:5%;
height:60px;
opacity:0.3;
position:absolute;
top:50%;
margin-top:-30px;
cursor:pointer;
background:#000;
}
#controls label:hover { opacity:0.8; }
#slide1:checked ~ #controls label:nth-child(2), #slide2:checked ~ #controls label:nth-child(3);
#slide2:checked ~ #controls label:nth-child(1), #slide3:checked ~ #controls label:nth-child(2);
Try z-index for your radio buttons. For example in their css add z-index:100.
#slides input {
position: relative;
left: 30px;
top: 500px;
z-index:100;
}
Related
I want to add to this slider another slide:
codepen.io/miriamcc/pen/KzGGqZ
But I don't know how to calculate all settings in CSS, maybe someone have similar slider without JS or know how to increase slides number?
#EDIT
I fixed it myself:
codepen.io/m17ek/pen/LYQyzbo
Here you go:
for future calculations when you add another slide :
duplicate this
/* add slide id here */
#slide4:checked ~ .images .images-inner {
/* increase this by 100% */
margin-left: -300%;
}
/* add nth child after comma(,) near Color of bullets */
/* add nth child after comma(,) near Text of slides */
/* add this and replace 4 with child count and increase time after infinite by 4100ms */
#play1:checked ~ div .fake-radio .radio-btn:nth-child(4) {
animation: bullet 12300ms infinite 11300ms;
}
/* do like above for this as well */
#play1:checked ~ .labels .label:nth-child(4) {
animation: caption 12300ms infinite 11300ms;
}
.image {
width: 100%;
height: 200px;
}
.radio {
/*display: none;*/
}
.images {
overflow: hidden;
top: 0;
bottom: 0;
left: 0;
right: 0;
width: 100%;
}
.images-inner {
width: 500%;
transition: all 800ms cubic-bezier(0.770, 0.000, 0.175, 1.000);
transition-timing-function: cubic-bezier(0.770, 0.000, 0.175, 1.000);
}
.image-slide {
width: 20%;
float: left;
}
.image-slide,
.fake-radio,
.radio-btn {
transition: all 0.5s ease-out;
}
.fake-radio {
float: right;
}
/* Move slides overflowed container */
#slide1:checked ~ .images .images-inner {
margin-left: 0;
}
#slide2:checked ~ .images .images-inner {
margin-left: -100%;
}
#slide3:checked ~ .images .images-inner {
margin-left: -200%;
}
#slide4:checked ~ .images .images-inner {
margin-left: -300%;
}
/* Color of bullets */
#slide1:checked ~ div .fake-radio .radio-btn:nth-child(1),
#slide2:checked ~ div .fake-radio .radio-btn:nth-child(2),
#slide3:checked ~ div .fake-radio .radio-btn:nth-child(3),
#slide3:checked ~ div .fake-radio .radio-btn:nth-child(4){
background: red;
}
.radio-btn {
width: 9px;
height: 9px;
border-radius: 5px;
background: gray;
display: inline-block !important;
margin: 0 1px;
cursor: pointer;
}
/* Color of bullets - END */
/* Text of slides */
#slide1:checked ~ .labels .label:nth-child(1),
#slide2:checked ~ .labels .label:nth-child(2),
#slide3:checked ~ .labels .label:nth-child(3),
#slide4:checked ~ .labels .label:nth-child(4){
opacity: 1;
}
.label {
opacity: 0;
position: absolute;
}
/* Text of slides - END */
/* Calculate AUTOPLAY for BULLETS */
#keyframes bullet {
0%, 33.32333333333334% {
background: red;
}
33.333333333333336%, 100% {
background: gray;
}
}
#play1:checked ~ div .fake-radio .radio-btn:nth-child(1) {
animation: bullet 12300ms infinite -1000ms;
}
#play1:checked ~ div .fake-radio .radio-btn:nth-child(2) {
animation: bullet 12300ms infinite 3100ms;
}
#play1:checked ~ div .fake-radio .radio-btn:nth-child(3) {
animation: bullet 12300ms infinite 7200ms;
}
#play1:checked ~ div .fake-radio .radio-btn:nth-child(4) {
animation: bullet 12300ms infinite 11300ms;
}
/* Calculate AUTOPLAY for BULLETS - END */
/* Calculate AUTOPLAY for SLIDES */
#keyframes slide {
0%, 25.203252032520325% { margin-left: 0; }
33.333333333333336%, 58.53658536585366% { margin-left: -100%; }
66.66666666666667%, 91.869918699187% { margin-left: -200%; }
}
.st-slider > #play1:checked ~ .images .images-inner {
animation: slide 12300ms infinite;
}
/* Calculate AUTOPLAY for SLIDES - END */
/* Calculate AUTOPLAY for CAPTION */
#keyframes caption {
0%, 33.32333333333334% {
opacity: 1;
}
33.333333333333336%, 100% {
opacity: 0;
}
}
#play1:checked ~ .labels .label:nth-child(1) {
animation: caption 12300ms infinite -1000ms;
}
#play1:checked ~ .labels .label:nth-child(2) {
animation: caption 12300ms infinite 3100ms;
}
#play1:checked ~ .labels .label:nth-child(3) {
animation: caption 12300ms infinite 7200ms;
}
#play1:checked ~ .labels .label:nth-child(4) {
animation: caption 12300ms infinite 11300ms;
}
/* Calculate AUTOPLAY for CAPTION - END */
<h1>Pure CSS slider</h1><pre>(with Autoplay at the beginning)</pre><br>
<div id="homepage-slider" class="st-slider">
<input type="radio" class="cs_anchor radio" name="slider" id="slide1"/>
<input type="radio" class="cs_anchor radio" name="slider" id="slide2"/>
<input type="radio" class="cs_anchor radio" name="slider" id="slide3"/>
<input type="radio" class="cs_anchor radio" name="slider" id="slide4" checked=""/>
<div class="images">
<div class="images-inner">
<div class="image-slide">
<div class="image bg-yellow" style="background-color:yellow;">image slide 1</div>
</div>
<div class="image-slide">
<div class="image bg-blue" style="background-color:pink;">imager slide 2</div>
</div>
<div class="image-slide">
<div class="image bg-red" style="background-color:orange;">image slide 3</div>
</div>
<div class="image-slide">
<div class="image bg-blue" style="background-color:lightblue;">image slide 4</div>
</div>
</div>
</div>
<div class="labels">
<label for="slide1" class="label">text slide 1</label>
<label for="slide2" class="label">text slide 2</label>
<label for="slide3" class="label">text slide 3</label>
<label for="slide4" class="label">text slide 4</label>
<div class="fake-radio">
<label for="slide1" class="radio-btn"></label>
<label for="slide2" class="radio-btn"></label>
<label for="slide3" class="radio-btn"></label>
<label for="slide4" class="radio-btn"></label>
</div>
</div>
</div>
I have tried z-index on input but its not working how can I fix that and please check this my other other question put my mistakes up
Why when radio button is checked the images are not sliding out of out of container?
please resolve my confusion
body {
font-family: sans-serif;
}
.img-container {
width: 1550px;
border: 4px solid black;
padding: 6px;
}
.crousel {
width: 516px;
border: 6px solid magenta;
height: 350px;
display: flex;
}
img {
padding: 6px;
}
.toggle-button {
display: none;
}
.box {
transition-duration: 1s;
transition-property: transform;
transition-timing-function: ease-in-out;
}
.toggle-button:nth-child(1):checked ~ .box:nth-child(1) {
transform: translateX(0);
}
.toggle-button:nth-child(2):checked ~ .box:nth-child(2) {
transform: translateX(-100%);
}
.toggle-button:nth-child(2):checked ~ .box:nth-child(2){
transform: translateX(-200%);
}
input {
z-index: 100;
}
<!DOCTYPE html>
<html>
<head>
<title>Parcel Sandbox</title>
<meta charset="UTF-8" />
<link rel="stylesheet" href="./src/styles.css" />
</head>
<body>
<div class="img-container">
<div class="crousel">
<input type="radio" name="button" id="toggle1" class="toggle-button" />
<input type="radio" name="button" id="toggle2" class="toggle-button" />
<input type="radio" name="button" id="toggle3" class="toggle-button" />
<img
src="https://cdn.pixabay.com/photo/2020/10/06/11/50/dog-5632005__340.jpg"
alt=""
class="box"
/>
<img
src="https://cdn.pixabay.com/photo/2020/09/12/09/26/gorilla-5565295__340.jpg"
alt=""
class="box"
/>
<img
src="https://cdn.pixabay.com/photo/2020/09/14/17/19/beach-5571545__340.jpg"
alt=""
class="box"
/>
</div>
</div>
<div class="buttons">
<label for="toggle1">1</label>
<label for="toggle2">2</label>
<label for="toggle3">3</label>
</div>
</body>
</html>
uhh I dont know what you are trying to make but i made it work. For some reason nth-child(1) was not working for box so i gave it box-1 box-2 box-3 classes and now it is working. lmk if it helped you
.toggle-button:nth-child(1):checked ~ .box-1 {
transform: translateX(0);
}
.toggle-button:nth-child(2):checked ~ .box-2 {
transform: translateX(-100%);
}
.toggle-button:nth-child(2):checked ~ .box-3{
transform: translateX(-200%);
}
<img src="https://cdn.pixabay.com/photo/2020/10/06/11/50/dog-5632005__340.jpg" alt="" class="box box-1"/>
<img src="https://cdn.pixabay.com/photo/2020/09/12/09/26/gorilla-5565295__340.jpg" alt="" class="box box-2"/>
<img src="https://cdn.pixabay.com/photo/2020/09/14/17/19/beach-5571545__340.jpg" alt="" class="box box-3"/>
You have set display property of your toggle-button to none. Simply replace the none with block
.toggle-button {
display: block;
}
I have a method that displays an image, and when clicked, displays a simple caption. The caption simply appears and disappears when tapped. However, it would be more interesting to move/fade the caption with a transition or effect as it appears and disappears.
Question
How can I add a move/fade effect to the caption using CSS/HTML in the
existing code?
Demo
https://codepen.io/anon/pen/gWYQoG
HTML
<div class="gallery-image">
<input type="checkbox" id="gallery" />
<label for="gallery">
<div class="gallery-image-icon">
<img src="https://upload.wikimedia.org/wikipedia/commons/thumb/9/96/Georges_Seurat_026.jpg/309px-Georges_Seurat_026.jpg" alt=“Gallery." height="240" width="309">
</div>
</label>
<div class="gallery-image-button">The quick brown fox jumps over the lazy dog.</div>
</div>
CSS
.gallery-image {
}
.gallery-image-icon {
cursor: pointer;
}
#gallery {
display:none;
}
#gallery:not(:checked) ~ .gallery-image-button {
display:none;
}
#gallery:checked ~ .gallery-image-button {
display:block;
}
Here is the transition with some movement
.gallery-image-button {
position: relative;
top: -30px;
opacity: 0;
}
#gallery:not(:checked)~.gallery-image-button {
position: relative;
display: block;
opacity: 0;
top: -30px;
transition: all .5s ease-in-out;
}
#gallery:checked~.gallery-image-button {
display: block;
opacity: 1;
top: 0;
transition: all .5s ease-in-out;
}
input {
display: none;
}
<div class="gallery-image">
<input type="checkbox" id="gallery" />
<label for="gallery">
<div class="gallery-image-icon">
<img src="https://upload.wikimedia.org/wikipedia/commons/thumb/9/96/Georges_Seurat_026.jpg/309px-Georges_Seurat_026.jpg" alt=“Gallery." height="240" width="309">
</div>
</label>
<div class="gallery-image-button">The quick brown fox jumps over the lazy dog.</div>
Here you go :
#gallery:not(:checked) ~ .gallery-image-button {
display:block;
opacity:0;
transition: all .5s ease-in-out;
}
#gallery:checked ~ .gallery-image-button {
display:block;
opacity:1;
transition: all .5s ease-in-out;
}
I'm trying to get a light black overlay on the image when you hover on it (like the text) sorry I'm new to css and HTML!
help would be appreciated
HTML
<div id="con">
<div id="box1">
<p id="text1">
DESTINATIONS
</p>
</p>
<p id="text2">
AMALFI<BR>SORRENTO<BR>POSITANO</a>
</p>
<p id="text3">
THINGS TO DO
</p>
</p>
<p id="text4">
TOURS<BR>MUSUEMS<BR>SHOPPING</a>
</p>
</div>
css
#con {
width:1024px;
height:670px;
background-color: #161717;
}
#box1 {
float: left;
font-size: 25px;
width: 388px;
height: 477px;
background-image: url(media/trying1.png);
background-size: cover;
margin-left: 120px;
margin-top: 90px;
}
#text1 {
z-index:100;
color:white;
font-size:30px;
text-align: center;
margin-top:80px;
line-height:55px;
opacity: 0;
transition: all 0.5s;
}
#box1:hover #text1 {
opacity: 1;
}
This can be done with :before or :after
#box1{
position:relative;
}
#box1:before{
content:'';
position:absolute;
top:0;
left:0;
right:0;
bottom:0;
background:black;
opacity:0;
z-index:0;
}
#box1:hover:before{
opacity:.6;
transition: all 0.5s;
}
#box1 > *{
position:relative;
z-index:1;
}
http://jsfiddle.net/4bo4zju7/3/
CS3 is great! You no longer need JS for simple rollover effects. Gopalraju's above code should work and so does my example below. You can have a fiddle with it and use the code as you see fit.
The parent div, has a black page background, and the imgdiv changes everything inside it to a opacity by 50% on the mouse rolling over the div. In this case the image is inside the div.
There are a few ways of doing this. This is just another one to ad into the mix. Good luck.
.parentdiv {
background-color:#000;
height:100%;
width:100%;
}
.imgdiv {
padding:30px;
}
.imgdiv a{
opacity: 1;
filter: alpha(opacity=100);
-webkit-transition: opacity 0.5s linear;
}
.imgdiv a:hover {
opacity: 0.5;
filter: alpha(opacity=50);
-webkit-transition: opacity 0.5s linear;
}
<div class="parentdiv">
<div class="imgdiv">
<a href="http://www.domain.com.au/link.html">
<img src="http://placehold.it/350x150" alt="image" height="150" width="350">
</a>
</div>
</div>
I'm trying to set multiple black transparency images on hover multiple thumbnail images and each image has a different position. To ensure this, each image has his own class (img1, img2, img3...) with different margins defined.
HTML
<div data-content="Text here" class="image">
<div class="img1">
<img src="../img1">
</div>
</div>
<div data-content="Text here" class="image">
<div class="img2">
<img src="../img2">
</div>
</div>
CSS IMG
.img1 {
height:200px;
position:relative;
margin-top:-10%;
}
.img2 {
height:200px;
position:relative;
left:10%;
}
CSS TRANSPARENCY
.image {
position:relative;
width:200px;
height:200px;
}
.image img {
width:100%;
vertical-align:top;
}
.image:after {
content: attr(data-content);
color:#fff;
position:absolute;
width:100%; height:100%;
top:0; left:0;
background:rgba(0,0,0,0.6);
opacity:0;
transition: all 0.5s;
-webkit-transition: all 0.5s;
}
.image:hover:after {
opacity:1;
}
I think you may have too many wrappers but here is one way with a slightly simpler structure
JSfiddle
HTML
<div class="thumbnail" data-content="Text here">
<img src="http://lorempixel.com/output/people-q-c-200-200-5.jpg"/>
</div>
<div class="thumbnail" data-content="Text here">
<img src="http://lorempixel.com/output/transport-q-c-200-200-6.jpg"/>
</div>>
CSS
.thumbnail {
display: inline-block;
position: relative;
}
.thumbnail a,
.thumbnail a img {
display: block;
}
.thumbnail:after {
content: attr(data-content);
color:transparent;
position:absolute;
width:100%; height:100%;
top:0;
left:0;
background:rgba(0,0,0,0.0);
transition: all 0.5s;
-webkit-transition: all 0.5s;
}
.thumbnail:hover:after {
background:rgba(0,0,0,0.6);
color:#fff;
}