CSS viewing trouble? - html

I have a problem when I click an arrow a second time to view the next slide the arrow disappears until I move the mouse again. I was wondering if it's possible to keep the arrow in view like the first click when the pointer is hovering over the arrows.
Here is the link to the Jsfiddle https://jsfiddle.net/2hmb60w0/
HTML
<form class="sliders">
<input type="radio" name="slider-choice" id="first-slider" checked />
<div class="slider-container">
<div class="slider">
<p>Some Random Text...</p>
</div>
<div class="nav">
<label for="second-slider" class="prev"></label>
<label for="second-slider" class="next"></label>
</div>
</div>
<input type="radio" name="slider-choice" id="second-slider" />
<div class="slider-container">
<div class="slider">
<p>Even Some More Random Text...</p>
</div>
<div class="nav">
<label for="first-slider" class="prev"></label>
<label for="first-slider" class="next"></label>
</div>
</div>
</form>
CSS
.sliders {
width: 600px;
position: relative;
}
.sliders input{
display: none;
}
.slider {
position: absolute;
opacity: 0;
width: 600px;
transform: scale(0);
transition: all .6s ease-in-out;
}
.nav label {
margin-top: 65px;
width: 85px;
display: none;
position: absolute;
opacity: 0;
cursor: pointer;
transition: opacity .2s;
color: black;
font-size: 6em;
text-align: center;
background-color: rgba(100, 100, 100, .6);
}
.slider:hover + .nav label, .slider:focus + .nav label{
opacity: 0.6;
}
.nav label:hover, .nav label:focus{
opacity: 1;
}
.nav .next{
right: 0;
}
.prev:before{
content: '\2770';
}
.next:before{
content: '\2771';
}
input:checked + .slider-container .slider{
opacity: 1;
transform: scale(1);
transition: opacity 2s ease-in-out;
}
input:checked + .slider-container .nav label{
display: block;
}
p{
padding: 100px 20px;
width: 560px;
text-align: center;
background: #dae1ef;
}

Add a z-index to the nav label to fix this
.nav label {
...
z-index: 9999;
}

If you change the opacity of the .nav label you can have the arrow show up at any level all the time:
.nav label {
margin-top: 65px;
width: 85px;
display: none;
position: absolute;
opacity: 0.5; //I set this to 0.5 (50%), so it is always visible.
//moving the mouse will make it more solid though
cursor: pointer;
transition: opacity .2s;
color: black;
font-size: 6em;
text-align: center;
background-color: rgba(100, 100, 100, .6);
}
Is that what you wanted to do?

I figured it out what I needed to do. Here is what I added to solve my problem.
CSS
.sliders:hover .nav label{
opacity: 0.5;
}

Related

Using image for checkbox input

First, please do not mark this as duplicate, cause I want to ask a little modification from this QnA, here. I'm using this answer to achieve what I want, but it almost meets what I need. Here is his demo.
I am trying to achieve what he did, this is what I've made so far. But, when I click the image, because of the border, it makes the images a little get bigger. What I want is, when the image (checkbox) checked, there are checkboxes icon on the top left (its done) and the image surrounds with a border without making the image get bigger. Here is the code in my snippet:
here is the HTML:
<ul>
<li><input type="checkbox" id="cb1" />
<label for="cb1"><img src="http://lorempixel.com/103/103" /></label>
</li>
<li><input type="checkbox" id="cb2" />
<label for="cb2"><img src="http://lorempixel.com/102/102" /></label>
</li>
</ul>
this is the CSS:
ul {
list-style-type: none;
}
li {
display: inline-block;
}
input[type="checkbox"][id^="cb"] {
display: none;
}
label {
display: block;
position: relative;
cursor: pointer;
width: 100%;
height: 100%;
}
label:before {
background-color: red;
color: white;
display: block;
border: 1px solid red;
position: absolute;
width: 20px;
height: 20px;
text-align: center;
line-height: 20px;
transition-duration: 0.4s;
-webkit-transition-duration: 0.4s;
-moz-transition-duration: 0.4s;
-ms-transition-duration: 0.4s;
}
label img {
height: 100%;
width: 100%;
}
:checked + label {
border-color: red;
}
:checked + label:before {
content: "✓";
background-color: red;
border: 1px solid red;
z-index: 99;
}
:checked + label img {
z-index: -1;
border: 1px solid red;
}
Thank you!
Add Border for img with transparent
label img {
height: 100%;
width: 100%;
border: 1px solid transparent;
}
https://codepen.io/anon/pen/PVRxRM
I gave fixed height and width to li and when the checkbox is checked i am changing the height and width of an image and aligning it in the center. hope this is what you are looking for. thanks.
ul {
list-style-type: none;
}
li {
display: inline-block;
}
input[type="checkbox"][id^="cb"] {
display: none;
}
label {
display: block;
position: relative;
cursor: pointer;
height: 120px;
border: 1px solid;
width: 120px;
}
label:before {
background-color: red;
color: white;
display: block;
position: absolute;
width: 20px;
height: 20px;
text-align: center;
line-height: 20px;
transition-duration: 0.4s;
}
label img {
height: 100%;
width: 100%;
}
:checked + label {
border-color: red;
}
:checked + label:before {
content: "✓";
background-color: red;
border: 1px solid red;
z-index: 99;
}
:checked + label img {
z-index: -1;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
height: 100px;
width: 100px;
}
<ul>
<li><input type="checkbox" id="cb1" />
<label for="cb1"><img src="http://lorempixel.com/100/100" /></label>
</li>
<li><input type="checkbox" id="cb2" />
<label for="cb2"><img src="http://lorempixel.com/101/101" /></label>
</li>
<li><input type="checkbox" id="cb3" />
<label for="cb3"><img src="http://lorempixel.com/102/102" /></label>
</li>
<li><input type="checkbox" id="cb4" />
<label for="cb4"><img src="http://lorempixel.com/103/103" /></label>
</li>
</ul>
Try This:
ul {
list-style-type: none;
}
li {
display: inline-block;
}
input[type="checkbox"][id^="cb"] {
display: none;
}
label {
border: 1px solid #fff;
display: block;
position: relative;
cursor: pointer;
}
label:before {
background-color: red;
color: white;
content: "";
display: block;
border: 1px solid red;
position: absolute;
width: 20px;
height: 20px;
text-align: center;
line-height: 20px;
transition-duration: 0.4s;
transform: scale(0);
}
label img {
height: 100%;
width: 100%;
transition-duration: 0.2s;
transform-origin: 50% 50%;
}
:checked + label {
border-color: red;
}
:checked + label:before {
content: "✓";
background-color: red;
z-index: 99;
transform: scale(1);
}
:checked + label img {
z-index: -1;
transform: scale(0.9);
}
<ul>
<li><input type="checkbox" id="cb1" />
<label for="cb1"><img src="http://lorempixel.com/103/103" /></label>
</li>
<li><input type="checkbox" id="cb2" />
<label for="cb2"><img src="http://lorempixel.com/102/102" /></label>
</li>
</ul>
So if requirement is when you click on image, you need to show ✓ on left top corner of image, and you also want to show some border around image, then what you have done is absolutely right.
If you are concerned about image moving by n pixel, then keep in mind that border occupy some space unlike outline which doesnt need any space. Outline takes n pixel around object and apply border type effect.
So there are 2 solution -
what #lalji suggested above. when you load page, apply border on image with color as transparent so it will reserve the space for your border and actually you will not see any border around it, and on clicking (selecting image) just change the color of border.
Fiddle for border transparent
label img {
height: 100%;
width: 100%;
border: 1px solid transparent;
}
another will be when you click it, apply the outline instead of border.
Fiddle for outline
:checked + label img {
z-index: -1;
outline: 1px solid red;
}
UPADTE if we want to show some image/text also when image selected. if you see here I have added another node saying details that will be shown only when image selected and will be aligned in centre of the image.
Fiddle
This below css rule to hide the details initially and making them in centre etc.
label img + .details
{
color:white;
position:absolute;
top:0px;
width:100%;
display:none;
margin-top:50%;
transform: translatey(-50%);
text-align:center;
}
Now, we will show the details section if image selected.
:checked + label img + .details
{
display:block;
}
You can use a "label" tag that contains an "img" tag inside.
Here's an example of using an image as a checkbox and radio.
* {
font-family: Lato;
margin: 0;
padding: 0;
--transition: 0.15s;
--border-radius: 0.5rem;
--background: #ffc107;
--box-shadow: #ffc107;
}
.cont-bg {
min-height: 100vh;
background-image: radial-gradient(
circle farthest-corner at 7.2% 13.6%,
rgba(37, 249, 245, 1) 0%,
rgba(8, 70, 218, 1) 90%
);
padding: 1rem;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.cont-title {
color: white;
font-size: 1.25rem;
font-weight: 600;
margin-bottom: 1rem;
}
.cont-main {
display: flex;
flex-wrap: wrap;
align-content: center;
justify-content: center;
}
.cont-checkbox {
width: 150px;
height: 100px;
border-radius: var(--border-radius);
box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
background: white;
transition: transform var(--transition);
}
.cont-checkbox:first-of-type {
margin-bottom: 0.75rem;
margin-right: 0.75rem;
}
.cont-checkbox:active {
transform: scale(0.9);
}
input {
display: none;
}
input:checked + label {
opacity: 1;
box-shadow: 0 0 0 3px var(--background);
}
input:checked + label img {
-webkit-filter: none; /* Safari 6.0 - 9.0 */
filter: none;
}
input:checked + label .cover-checkbox {
opacity: 1;
transform: scale(1);
}
input:checked + label .cover-checkbox svg {
stroke-dashoffset: 0;
}
label {
display: inline-block;
cursor: pointer;
border-radius: var(--border-radius);
overflow: hidden;
width: 100%;
height: 100%;
position: relative;
opacity: 0.6;
}
label img {
width: 100%;
height: 70%;
object-fit: cover;
clip-path: polygon(0% 0%, 100% 0, 100% 81%, 50% 100%, 0 81%);
-webkit-filter: grayscale(100%); /* Safari 6.0 - 9.0 */
filter: grayscale(100%);
}
label .cover-checkbox {
position: absolute;
right: 5px;
top: 3px;
z-index: 1;
width: 20px;
height: 20px;
border-radius: 50%;
background: var(--box-shadow);
border: 2px solid #fff;
transition: transform var(--transition),
opacity calc(var(--transition) * 1.2) linear;
opacity: 0;
transform: scale(0);
}
label .cover-checkbox svg {
width: 13px;
height: 11px;
display: inline-block;
vertical-align: top;
fill: none;
margin: 5px 0 0 3px;
stroke: #fff;
stroke-width: 2;
stroke-linecap: round;
stroke-linejoin: round;
stroke-dasharray: 16px;
transition: stroke-dashoffset 0.4s ease var(--transition);
stroke-dashoffset: 16px;
}
label .info {
text-align: center;
margin-top: 0.2rem;
font-weight: 600;
font-size: 0.8rem;
}
<div class="cont-bg">
<div class="cont-title">Checkbox</div>
<div class="cont-main">
<div class="cont-checkbox">
<input type="checkbox" id="myCheckbox-1" />
<label for="myCheckbox-1">
<img
src="https://hips.hearstapps.com/hmg-prod.s3.amazonaws.com/images/2021-mazda-mx-5-miata-mmp-1-1593459650.jpg?crop=0.781xw:0.739xh;0.109xw,0.0968xh&resize=480:*"
/>
<span class="cover-checkbox">
<svg viewBox="0 0 12 10">
<polyline points="1.5 6 4.5 9 10.5 1"></polyline>
</svg>
</span>
<div class="info">Mazda MX-5 Miata</div>
</label>
</div>
<div class="cont-checkbox">
<input type="checkbox" id="myCheckbox-2" />
<label for="myCheckbox-2">
<img
src="https://hips.hearstapps.com/hmg-prod.s3.amazonaws.com/images/2020-chevrolet-corvette-c8-102-1571146873.jpg?crop=0.548xw:0.411xh;0.255xw,0.321xh&resize=980:*"
/>
<span class="cover-checkbox">
<svg viewBox="0 0 12 10">
<polyline points="1.5 6 4.5 9 10.5 1"></polyline>
</svg>
</span>
<div class="info">Toyota Supra</div>
</label>
</div>
</div>
<div class="cont-title">Radio</div>
<div class="cont-main">
<div class="cont-checkbox">
<input type="radio" name="myRadio" id="myRadio-1" />
<label for="myRadio-1">
<img
src="https://hips.hearstapps.com/hmg-prod.s3.amazonaws.com/images/2021-mazda-mx-5-miata-mmp-1-1593459650.jpg?crop=0.781xw:0.739xh;0.109xw,0.0968xh&resize=480:*"
/>
<span class="cover-checkbox">
<svg viewBox="0 0 12 10">
<polyline points="1.5 6 4.5 9 10.5 1"></polyline>
</svg>
</span>
<div class="info">Mazda MX-5 Miata</div>
</label>
</div>
<div class="cont-checkbox">
<input type="radio" name="myRadio" id="myRadio-2" />
<label for="myRadio-2">
<img
src="https://hips.hearstapps.com/hmg-prod.s3.amazonaws.com/images/2020-chevrolet-corvette-c8-102-1571146873.jpg?crop=0.548xw:0.411xh;0.255xw,0.321xh&resize=980:*"
/>
<span class="cover-checkbox">
<svg viewBox="0 0 12 10">
<polyline points="1.5 6 4.5 9 10.5 1"></polyline>
</svg>
</span>
<div class="info">Toyota Supra</div>
</label>
</div>
</div>
</div>

toggle switch with text beside it

I'm having trouble getting a toggle switch from the w3c tutorial to line up with some text beside it.
this is the tutorial https://www.w3schools.com/howto/howto_css_switch.asp
and this is my code:
<div class="sliderWrapper">
<div><?php echo __('Postal Address');?> </div>
<label class="switch">
<input type="checkbox" name="data[SplashPage][firstname]">
<span class="slider"></span>
</label>
</div>
<div class="sliderWrapper">
<div><?php echo __('Postal Address');?> </div>
<label class="switch">
<input type="checkbox" name="data[SplashPage][lastname]">
<span class="slider"></span>
</label>
</div>
.sliderWrapper{display: inline-block;margin:24px 24px 24px 24px;}
.sliderWrapper div{display: inline-block;line-height:60px;}
.switch {
position: relative;
display: inline-block;
padding:0px;
width: 54px;
height: 28px;
}
/* Hide default HTML checkbox */
.switch input {display:none;}
/* The slider */
.slider {
position: absolute;
cursor: pointer;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: #d7d7d7;
-webkit-transition: .4s;
transition: .4s;
}
.slider:before {
position: absolute;
content: "";
height: 26px;
width: 26px;
left: 1px;
bottom: 1px;
background-color: white;
-webkit-transition: .4s;
transition: .4s;
}
input:checked + .slider {background-color: #1fb5ad;}
input:focus + .slider {box-shadow: 0 0 1px #1fb5ad;}
input:checked + .slider:before {-webkit-transform: translateX(26px);
-ms-transform: translateX(26px);transform: translateX(26px);}
Can anyone help me out with making the text be vertically aligned with the switch - been banging my head on the table of hours now :-(
jsfiddle: https://jsfiddle.net/vfjgtaoh/
Add the line:
vertical-align: middle;
to your switch class, this will vertically align the contents
Fiddle: https://jsfiddle.net/tzv75zvk/
Add Vertical-align:middle; property to label tag and remove line-height for the div
.sliderWrapper div{
display: inline-block;
}
.switch {
position: relative;
display: inline-block;
padding:0px;
vertical-align:middle;
width: 54px;
height: 28px;
}
Link for reference

Align label with css 3 fancy radio button

I have the following radio button, I need the bigger circle to be 38px
input[type=radio] {
visibility: hidden;
}
.label {
font-weight: normal;
color: #333;
}
.label::before {
content: '';
position: absolute;
left: 0;
width: 38px;
height: 38px;
border: 1px solid #727272;
border-radius: 50%;
}
input[type=radio]:checked+label:after {
content: '';
position: absolute;
width: 38px;
height: 38px;
left: 0;
background: #0065bd;
border: none;
transform: scale(0.5);
border-radius: 50%;
}
<div class="container">
<input type="radio" id="radio1" value="on">
<label for="radio1" class="label">Yes</label>
</div>
Here is a fiddle, how can I align the label so it is aligned to the centered and pushed to the right of the circle?
Add .container{ line-height:38px} to have it centered (it seems that it was to the right already)
https://jsfiddle.net/8gubpzhq/
to move it to the right add this to the
.label {
font-weight: normal;
color: #333;
padding-left:5px;//add this line
}
https://jsfiddle.net/vszuu535/
You can add line-height:40px; to your .label to center it vertically. To move it over to the right more you can add padding-left:20px; (You can change the line-height and padding-left to fit your needs).
input[type=radio] {
visibility: hidden;
}
.label {
font-weight: normal;
color: #333;
line-height:40px;
padding-left:20px;
}
.label::before {
content: '';
position: absolute;
left: 0;
width: 38px;
height: 38px;
border: 1px solid #727272;
border-radius: 50%;
}
input[type=radio]:checked + label:after {
content: '';
position: absolute;
width: 38px;
height: 38px;
left: 0;
background: #0065bd;
border: none;
transform: scale(0.5);
border-radius: 50%;
}
<div class="container">
<input type="radio" id="radio1" value="on">
<label for="radio1" class="label">Yes</label>
</div>
Perhaps your code is over-complicating matters; as you want the input to be bigger, maybe you should focus the sizing etc on the input rather than the label?
See the snippet (the radio turns blue now since edit, adapted from this codepen. It's grey before click, blue after, centered, and indented from the edge).
Just a note: If you are going to use a default value (and only have one option) maybe a custom checkbox would be a more suitable choice? (Radios button are usually used in instances where the user would have 2 or more choices, but can only select one).. just a thought.
input[type="radio"] {
display: none;
width: 38px;
height: 38px;
border: 1px solid #727272;
}
input[type="radio"]+label span {
display: inline-block;
width: 38px;
height: 38px;
margin: 9px;
vertical-align: middle;
cursor: pointer;
border-radius: 50%;
background-color: grey;
}
input[type="radio"]:checked+label span {
content="";
background: #0065bd;
}
input[type="radio"]+label span,
input[type="radio"]:checked+label span {
-webkit-transition: background-color 0.4s linear;
-o-transition: background-color 0.4s linear;
-moz-transition: background-color 0.4s linear;
transition: background-color 0.4s linear;
}
<div class="container">
<input type="radio" id="radio1" name="radio">
<label for="radio1" class="label"><span></span>Yes</label>
<input type="radio" id="radio2" name="radio">
<label for="radio2" class="label"><span></span>No</label>
</div>

How to make CSS Slider to autoplay

I have this simple HTML/CSS slider with only 2 slides.
I need to make it autoplay the slides every 7 seconds.
I am not familiar with jquery or javascript, so it would be easier for me to implement a css solution...
Can you help?
You can see it in action right now at
http://www.hotelgalatas.com/test/
Thanks!
body {
overflow: hidden;
width: 100%;
height: 100%;
padding: 0;
margin: 0;
}
/* Slider wrapper*/
.css-slider-wrapper {
display: block;
background: #FFF;
overflow: hidden;
position: absolute;
left: 0;
right: 0;
top: 0;
bottom: 0;
}
/* Slider */
.slider {
width: 100%;
height: 100%;
background: #ccc;
position: absolute;
left: 0;
top: 0;
opacity: 1;
z-index: 0;
display: flex;
display: -webkit-flex;
display: -ms-flexbox;
flex-direction: row;
flex-wrap: wrap;
-webkit-flex-align: center;
-webkit-align-items: center;
align-items: center;
justify-content: center;
align-content: center;
-webkit-transition: -webkit-transform 1600ms;
transition: -webkit-transform 1600ms, transform 1600ms;
-webkit-transform: scale(1);
transform: scale(1);
}
/* each slide background color */
.slide1 {
background: #00bcd7;
left: 0;
}
.slide2 {
background: #009788;
left: 100%;
}
.slider>div {
text-align: center;
}
/* Slider inner slide effect */
.slider h2 {
color: #FFF;
font-weight: 900;
text-transform: uppercase;
font-size: 45px;
line-height: 120%;
opacity: 0;
-webkit-transform: translateX(500px);
transform: translateX(500px);
}
.slider .button {
color: #FFF;
padding: 5px 30px;
background: rgba(255, 255, 255, 0.3);
text-decoration: none;
opacity: 0;
font-size: 15px;
line-height: 30px;
display: inline-block;
-webkit-transform: translateX(-500px);
transform: translateX(-500px);
}
.slider h2,
.slider .button {
-webkit-transition: opacity 800ms, -webkit-transform 800ms;
transition: transform 800ms, opacity 800ms;
-webkit-transition-delay: 1s;
/* Safari */
transition-delay: 1s;
}
/* Next and Prev arrows */
.control {
position: absolute;
top: 50%;
width: 50px;
height: 50px;
margin-top: -25px;
z-index: 55;
}
.control label {
z-index: 0;
display: none;
text-align: center;
line-height: 50px;
font-size: 50px;
color: #FFF;
cursor: pointer;
opacity: 0.2;
}
.control label:hover {
opacity: 0.5;
}
.next {
right: 1%;
}
.previous {
left: 1%;
}
/* Slider Pager */
.slider-pagination {
position: absolute;
bottom: 20px;
width: 100%;
left: 0;
text-align: center;
z-index: 1000;
}
.slider-pagination label {
width: 10px;
height: 10px;
border-radius: 50%;
display: inline-block;
background: rgba(255, 255, 255, 0.2);
margin: 0 2px;
border: solid 1px rgba(255, 255, 255, 0.4);
cursor: pointer;
}
/* Slider Pager arrow event */
.slide-radio1:checked~.next .numb2,
.slide-radio2:checked~.previous .numb1 {
display: block;
z-index: 1
}
/* Slider Pager event */
.slide-radio1:checked~.slider-pagination .page1,
.slide-radio2:checked~.slider-pagination .page2 {
background: rgba(255, 255, 255, 1)
}
/* Slider slide effect */
.slide-radio1:checked~.slider {
-webkit-transform: translateX(0%);
transform: translateX(0%);
}
.slide-radio2:checked~.slider {
-webkit-transform: translateX(-100%);
transform: translateX(-100%);
}
.slide-radio1:checked~.slide1 h2,
.slide-radio2:checked~.slide2 h2,
.slide-radio1:checked~.slide1 .button,
.slide-radio2:checked~.slide2 .button {
-webkit-transform: translateX(0);
transform: translateX(0);
opacity: 1
}
#media only screen and (max-width: 767px) {
.slider h2 {
font-size: 20px;
}
.slider>div {
padding: 0 2%
}
.control label {
font-size: 35px;
}
.slider .button {
padding: 0 15px;
}
}
<div class="css-slider-wrapper">
<input type="radio" name="slider" class="slide-radio1" checked id="slider_1">
<input type="radio" name="slider" class="slide-radio2" id="slider_2">
<div class="slider-pagination">
<label for="slider_1" class="page1"></label>
<label for="slider_2" class="page2"></label>
</div>
<div class="next control">
<label for="slider_1" class="numb1"><i class="fa fa-arrow-circle-right"></i>
</label>
<label for="slider_2" class="numb2"><i class="fa fa-arrow-circle-right"></i>
</label>
</div>
<div class="previous control">
<label for="slider_1" class="numb1"><i class="fa fa-arrow-circle-left"></i>
</label>
<label for="slider_2" class="numb2"><i class="fa fa-arrow-circle-left"></i>
</label>
</div>
<div class="slider slide1">
<div>
<h2>First Slide Text</h2>
Button1 Button2 </div>
</div>
<div class="slider slide2">
<div>
<h2>Second Slide Text</h2>
Button1 Button2 </div>
</div>
</div>
to deal with time you have to use javascript/jquery.
you can access the slides by using class names and add/hide the elements every 7 seconds and use them with setInterval function.
var interval = setInterval(function () {document.getElementById('previous-control').addClass('hide'); document.getElementById('next-control').addClass('show'); }, 7000);
where you have to add the hide and show classes in css with display none and block

Fade back DIV on hover- even when hovering over front DIV

I'm looking for a CSS only solution to fade an image in a back DIV when hovering over any section of the DIV, including DIVs that are in front of it.
Here is what I've been able to build so far: http://jsfiddle.net/kqo10jLb/
The CSS:
#caseouter {
position: relative;
top: 0px;
}
#casewrap2 {
background-color: #000;
}
#casetitle {
font-size: 30px;
width: 100%;
display: block;
text-transform: uppercase;
text-align: center;
padding: 10px 0px 0px 0px;
color: #fff;
margin-bottom: 0px;
}
#casethumb {
width: 100%;
display: block;
margin-bottom: -100px;
opacity: 1;
transition: .2s opacity ease .2s;
height: 100px;
}
#casesecondline {
font-size: 30px;
color: #666;
text-transform: uppercase;
margin: 0 auto;
display: block;
width: 100%;
text-align: center;
color: #fff;
margin-top: -10px;
padding: 0px;
}
#casethumb img {
width: 100%;
}
#casethumb:hover {
opacity: .75;
}
#casetitle:hover ~ #casethumb a {
opacity: .75;
}
#casesecond:hover ~ #casethumb a {
opacity: .75;
}
And the HTML:
<div id="casewrap2">
<div id="casethumb">
<a href="www.google.com">
<img src="http://ringer.tv/wp-content/uploads/2014/08/case_bravo.jpg">
</a>
</div>
</div>
<div id="caseouter">
<a href="www.google.com">
<div id="casetitle">Headline</div>
<div id="casesecondline">Subheadline</div>
</a>
</div>
As you'll see, the back image fades on hover, however, it will not fade when I hover over the headline and subheadline text. I've tried using #casetitle:hover ~ #casethumb a but I'm obviously doing something wrong. Thanks!
Is this what you're after? http://jsfiddle.net/kqo10jLb/1/
I moved the caseouter into the casewrap2 object and changed the hover to this:
#casewrap2:hover #casethumb {
opacity: .75;
}