CSS :target on hover not on click - html

I've got a slider, and it's working great. BUT, I've got one little problem. I want to change the slider image when I hover over one of the <li>s, and not when I click on them.
Is this possible? I've found this link, but maybe there's some new style available already?
.slide {
position: absolute;
display: none;
left: -150;
}
.next {
font-size: 50px;
height: 50px;
line-height: 50px;
position: absolute;
top: calc(50% - 25px);
right: 0;
}
.prev {
font-size: 50px;
height: 50px;
line-height: 50px;
position: absolute;
top: calc(50% - 25px);
}
.slider .slide:target {
transition: 1s;
left: 0;
z-index: 999;
display: block;
}
ul {
padding-top: 250px
}
ul li:hover>a:target {
left: 0;
transition: 1s;
z-index: 9999;
}
<div class='slider'>
<div class='slide' id="slide1" style="display: block;">
<a class="prev" href="#slide4"><</a>
<img src="http://pic.1fotonin.com/data/wallpapers/9/WDF_576006.jpg" width="450" height="150" />
<a class="next" href="#slide2">></a>
</div>
<div class='slide' id="slide2">
<a class="prev" href="#slide1"><</a>
<img src="http://pic.1fotonin.com/data/wallpapers/9/WDF_575498.jpg" width="450" height="150" />
<a class="next" href="#slide3">></a>
</div>
<div class='slide' id="slide3">
<a class="prev" href="#slide1"><</a>
<img src="http://pic.1fotonin.com/data/wallpapers/9/WDF_576753.jpg" width="450" height="150" />
<a class="next" href="#slide4">></a>
</div>
<div class='slide' id="slide4">
<a class="prev" href="#slide3"><</a>
<img src="http://pic.1fotonin.com/data/wallpapers/9/WDF_575922.jpg" width="450" height="150" />
<a class="next" href="#slide1">></a>
</div>
</div>
<ul>
<li>Slide 1</li>
<li>Slide 2</li>
<li>Slide 3</li>
<li>Slide 4</li>
</ul>

Do you need to use :target? Please check out my Fiddle.
.slide
{
position: absolute;
display: none;
left:0;
}
ul
{
padding-top: 50px;
list-style:none;
}
ul li
{
display:inline-block;
}
ul li a
{
position:relative;
top:-50px;
left:0;
}
ul li a:hover + .slide
{
transition: 1s;
z-index: 9999;
display: block;
}
<div class='slider'>
<ul>
<li>
Slide 1
<div class='slide' id="slide1" style="display: block;">
<img src="https://i.picsum.photos/id/591/450/150.jpg" width="450" height="150" />
</div>
</li>
<li>
Slide 2
<div class='slide' id="slide2">
<img src="https://i.picsum.photos/id/402/450/150.jpg" width="450" height="150" />
</div>
</li>
<li>
Slide 3
<div class='slide' id="slide3">
<img src="https://i.picsum.photos/id/1067/450/150.jpg" width="450" height="150" />
</div>
</li>
<li>
Slide 4
<div class='slide' id="slide4">
<img src="https://i.picsum.photos/id/382/450/150.jpg" width="450" height="150" />
</div>
</li>
</ul>
</div>
I removed the next and before buttons for convenience, but it would also be simple to include them again.

Related

How to display a background color on heading?

This is my first time designing a site. I have a created a slideshow, and it's working fine. It's just that I want my heading to have a background color so that it can be seen over the image. But I don't know why background color is not working.
This is my html:
<div class="slideshow">
<div class="slideshow-item-container">
<div class="slideshow-item">
<a href="humans/embryonic-development.html">
<img src="img/baby.jpg" alt="A newborn baby"/>
<h2 class="item-text">The Qur'an on Human Embryonic Development</h2></a>
</div>
<div class="slideshow-item">
<a href="humans/the-cerebrum.html">
<img src="img/brain.jpg" alt="The Cerebrum and Its Parts"/>
<h2 class="item-text">The Cerebrum in Quran</h2> </a>
</div>
<div class="slideshow-item">
<a href="humans/the-cerebrum.html">
<img src="img/ocean.jpg" alt="The Cerebrum and Its Parts"/>
<h2 class="item-text">Where the oceans meet</h2> </a>
</div>
<div class="slideshow-item">
<a href="humans/embryonic-development.html">
<img src="img/baby.jpg" alt="A newborn baby"/>
<h2 class="item-text">The Qur'an on Human Embryonic Development</h2></a>
</div>
</div>
</div>
And the CSS:
*{
margin: 0;
padding: 0;
}
.slideshow {
overflow: hidden;
margin-top: 20px;
}
.slideshow-item-container {
position: relative;
width: 400%;
left: 0;
animation: 20s slider infinite;
}
.slideshow-item {
width: 25%;
float: left;
}
h2.item-text {
margin-top: -48px;
margin-right: 20px;
text-align: right;
background-color: #2b5072;
color: white;
}
Despite the background property, it's still not showing it. Here is a screenshot:
screenshot of site with no background color appearing on heading
Just because you scrolled the text on the picture, you need to add the code below to make it overlap.
You can examine the snippet to test it.
h2.item-text {
.
.
.
position: relative;
z-index: 1;
}
* {
margin: 0;
padding: 0;
}
.slideshow {
overflow: hidden;
margin-top: 20px;
}
.slideshow-item-container {
position: relative;
width: 400%;
left: 0;
animation: 20s slider infinite;
}
.slideshow-item {
width: 25%;
float: left;
}
h2.item-text {
margin-top: -48px;
margin-right: 20px;
text-align: right;
background-color: #2b5072;
color: white;
position: relative;
z-index: 1;
}
<div class="slideshow">
<div class="slideshow-item-container">
<div class="slideshow-item">
<a href="humans/embryonic-development.html">
<img src="https://placeimg.com/1640/380/any" alt="A newborn baby" />
<h2 class="item-text">The Qur'an on Human Embryonic Development</h2>
</a>
</div>
<div class="slideshow-item">
<a href="humans/the-cerebrum.html">
<img src="https://placeimg.com/1640/380/any" alt="The Cerebrum and Its Parts" />
<h2 class="item-text">The Cerebrum in Quran</h2>
</a>
</div>
<div class="slideshow-item">
<a href="humans/the-cerebrum.html">
<img src="https://placeimg.com/1640/380/any" alt="The Cerebrum and Its Parts" />
<h2 class="item-text">Where the oceans meet</h2>
</a>
</div>
<div class="slideshow-item">
<a href="humans/embryonic-development.html">
<img src="https://placeimg.com/1640/380/any" alt="A newborn baby" />
<h2 class="item-text">The Qur'an on Human Embryonic Development</h2>
</a>
</div>
</div>
</div>
Try changing your images to the background image of your div tag. Here is an example:
<div class="square" style="border:solid 1px red; height:150px;background-
image:url('https://www.campsitecoders.com/img/google-seo-search-engines.jpg')">
Photo 4
https://codepen.io/susanwinters/pen/wvWjvRb

Bootstrap carousel controls not reflecting the styles

I want my carousel controls to be something like this(Link at the end). and they should be outside the carousel. but when I tried to add styles, nothing seems to reflect, is there anything I am missing. Please help me out.
Thanks in advance.
Expected carousel control- left
.carousel-control .glyphicon-chevron-left, .carousel-control .glyphicon-chevron-right, .carousel-control .icon-next, .carousel-control .icon-prev {
position: absolute;
top: 83% !important;
z-index: 5;
display: inline-block;
margin-top: -10px;
}
h4 {
margin: 20px 10px 10px;
}
p {
margin: 10px;
}
#carousel-example-generic {
margin: 20px auto;
width: 400px;
}
#carousel-custom {
margin: 20px auto;
width: 400px;
}
#carousel-custom .carousel-indicators {
margin: 10px 0 0;
overflow: auto;
position: static;
text-align: left;
white-space: nowrap;
width: 100%;
}
#carousel-custom .carousel-indicators li {
background-color: transparent;
-webkit-border-radius: 0;
border-radius: 0;
display: inline-block;
height: auto;
margin: 0 !important;
width: auto;
}
#carousel-custom .carousel-indicators li img {
display: block;
opacity: 0.5;
}
#carousel-custom .carousel-indicators li.active img {
opacity: 1;
}
#carousel-custom .carousel-indicators li:hover img {
opacity: 0.75;
}
#carousel-custom .carousel-outer {
position: relative;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" integrity="sha256-7s5uDGW3AHqw6xtJmNNtr+OBRJUlgkNJEo78P4b0yRw= sha512-nNo+yCHEyn0smMxSswnf/OnX6/KwJuZTlNZBjauKhTK0c+zT+q5JOCx0UFhXQ6rJR9jg6Es8gPuD2uZcYDLqSw==" crossorigin="anonymous">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha256-KXn5puMvxCw+dAYznun+drMdG1IFl3agK0p/pqT9KAo= sha512-2e8qq0ETcfWRI4HJBzQiA3UoyFk6tbNyG+qSaIBZLyW9Xf3sWZHN/lxe9fTh1U45DpPf07yj94KsUHHWe4Yk1A==" crossorigin="anonymous"></script>
<div id='carousel-custom' class='carousel slide' data-ride='carousel'>
<div class='carousel-outer'>
<!-- Wrapper for slides -->
<div class='carousel-inner'>
<div class='item active'>
<img src='http://placehold.it/400x200&text=slide1' alt='' />
</div>
<div class='item'>
<img src='http://placehold.it/400x200&text=slide2' alt='' />
</div>
<div class='item'>
<img src='http://placehold.it/400x200&text=slide3' alt='' />
</div>
<div class='item'>
<img src='http://placehold.it/400x200&text=slide4' alt='' />
</div>
<div class='item'>
<img src='http://placehold.it/400x200&text=slide5' alt='' />
</div>
<div class='item'>
<img src='http://placehold.it/400x200&text=slide6' alt='' />
</div>
</div>
</div>
<!-- Controls -->
<a class='left carousel-control' href='#carousel-custom' data-slide='prev'>
<span class='glyphicon glyphicon-chevron-left'></span>
</a>
<a class='right carousel-control' href='#carousel-custom' data-slide='next'>
<span class='glyphicon glyphicon-chevron-right'></span>
</a>
<!-- Indicators -->
<ol class='carousel-indicators'>
<li data-target='#carousel-custom' data-slide-to='0' class='active'><img src='http://placehold.it/100x50&text=slide1' alt='' /></li>
<li data-target='#carousel-custom' data-slide-to='1'><img src='http://placehold.it/100x50&text=slide2' alt='' /></li>
<li data-target='#carousel-custom' data-slide-to='2'><img src='http://placehold.it/100x50&text=slide3' alt='' /></li>
<li data-target='#carousel-custom' data-slide-to='3'><img src='http://placehold.it/100x50&text=slide4' alt='' /></li>
<li data-target='#carousel-custom' data-slide-to='4'><img src='http://placehold.it/100x50&text=slide5' alt='' /></li>
<li data-target='#carousel-custom' data-slide-to='5'><img src='http://placehold.it/100x50&text=slide6' alt='' /></li>
</ol>
</div>
I want my carousel controls to be something like this(Link at the end). and they should be outside the carousel. but when I tried to add styles, nothing seems to reflect, is there anything I am missing. Please help me out.
Working Demo below: added the pic you give just customize the pic and upadte the image url.
.carousel-control img{
z-index: 5;
display: inline-block;
margin-top: 100%;
position:relative;
}
h4 {
margin: 20px 10px 10px;
}
p {
margin: 10px;
}
#carousel-example-generic {
margin: 20px auto;
width: 400px;
}
#carousel-custom {
margin: 20px auto;
width: 400px;
}
#carousel-custom .carousel-indicators {
margin: 10px 0 0;
overflow: auto;
position: static;
text-align: left;
white-space: nowrap;
width: 100%;
}
#carousel-custom .carousel-indicators li {
background-color: transparent;
-webkit-border-radius: 0;
border-radius: 0;
display: inline-block;
height: auto;
margin: 0 !important;
width: auto;
}
#carousel-custom .carousel-indicators li img {
display: block;
opacity: 0.5;
}
#carousel-custom .carousel-indicators li.active img {
opacity: 1;
}
#carousel-custom .carousel-indicators li:hover img {
opacity: 0.75;
}
#carousel-custom .carousel-outer {
position: relative;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" integrity="sha256-7s5uDGW3AHqw6xtJmNNtr+OBRJUlgkNJEo78P4b0yRw= sha512-nNo+yCHEyn0smMxSswnf/OnX6/KwJuZTlNZBjauKhTK0c+zT+q5JOCx0UFhXQ6rJR9jg6Es8gPuD2uZcYDLqSw=="
crossorigin="anonymous">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha256-KXn5puMvxCw+dAYznun+drMdG1IFl3agK0p/pqT9KAo= sha512-2e8qq0ETcfWRI4HJBzQiA3UoyFk6tbNyG+qSaIBZLyW9Xf3sWZHN/lxe9fTh1U45DpPf07yj94KsUHHWe4Yk1A==" crossorigin="anonymous"></script>
<a class='left carousel-control' href='#carousel-custom' data-slide='prev'>
<img src="https://i.stack.imgur.com/4HGNH.jpg" />
</a>
<a class='right carousel-control' href='#carousel-custom' data-slide='next'>
<img src="https://i.stack.imgur.com/4HGNH.jpg" />
</a>
<div id='carousel-custom' class='carousel slide' data-ride='carousel'>
<div class='carousel-outer'>
<!-- Wrapper for slides -->
<div class='carousel-inner'>
<div class='item active'>
<img src='http://placehold.it/400x200&text=slide1' alt='' />
</div>
<div class='item'>
<img src='http://placehold.it/400x200&text=slide2' alt='' />
</div>
<div class='item'>
<img src='http://placehold.it/400x200&text=slide3' alt='' />
</div>
<div class='item'>
<img src='http://placehold.it/400x200&text=slide4' alt='' />
</div>
<div class='item'>
<img src='http://placehold.it/400x200&text=slide5' alt='' />
</div>
<div class='item'>
<img src='http://placehold.it/400x200&text=slide6' alt='' />
</div>
</div>
</div>
<!-- Controls -->
<!-- Indicators -->
<ol class='carousel-indicators'>
<li data-target='#carousel-custom' data-slide-to='0' class='active'><img src='http://placehold.it/100x50&text=slide1' alt='' /></li>
<li data-target='#carousel-custom' data-slide-to='1'><img src='http://placehold.it/100x50&text=slide2' alt='' /></li>
<li data-target='#carousel-custom' data-slide-to='2'><img src='http://placehold.it/100x50&text=slide3' alt='' /></li>
<li data-target='#carousel-custom' data-slide-to='3'><img src='http://placehold.it/100x50&text=slide4' alt='' /></li>
<li data-target='#carousel-custom' data-slide-to='4'><img src='http://placehold.it/100x50&text=slide5' alt='' /></li>
<li data-target='#carousel-custom' data-slide-to='5'><img src='http://placehold.it/100x50&text=slide6' alt='' /></li>
</ol>
</div>

I want caption for image without hperlink underscore in horizontal view

<center><figure>
<img class="img-circle" src="doctor.png" height="70" width="70" hspace="30"/><figcaption>Doctors</figcaption>
<img class="img-circle" src="lab.jpg" height="70" width="70" hspace="30"/><figcaption>Labs</figcaption>
<img class="img-circle" src="spa.png" height="70" width="70" hspace="30"/><figcaption>Spa</figcaption>
<img class="img-circle" src="gym.png"height="70" width="70" hspace="30"/><figcaption>Gym</figcaption>
</center></figure>
I may have misunderstood the question but I think this is what you want.
I've used display: inline-block; so that each figure will display horizontally (of course if there is not enough space it will move to the next line).
I also moved your HTML around a little so each image has it's own figure.
figure {
display: inline-block;
text-align: center;
margin: 20px;
}
figure a {
text-decoration: none;
}
<center>
<figure>
<a href="#">
<img src="http://placehold.it/70x70" width="70" height="70">
<figcaption>Doctors</figcaption>
</a>
</figure>
<figure>
<a href="#">
<img src="http://placehold.it/70x70" width="70" height="70">
<figcaption>Labs</figcaption>
</a>
</figure>
<figure>
<a href="#">
<img src="http://placehold.it/70x70" width="70" height="70">
<figcaption>Gym</figcaption>
</a>
</figure>
<figure>
<a href="#">
<img src="http://placehold.it/70x70" width="70" height="70">
<figcaption>Spa</figcaption>
</a>
</figure>
</center>
Then of course you could start going a bit fancier, making it animated using css animations and using media queries
figure.menu {
position: relative;
display: inline-block;
text-align: center;
overflow: hidden;
height: 70px;
margin: 20px
}
figure.menu a {
text-decoration: none;
}
figure.menu figcaption {
position: absolute;
background: rgba(0, 0, 0, .5);
color: #fff;
bottom: -30%;
opacity: 0;
width: 100%;
transition: all .3s ease-in-out;
}
figure.menu:hover figcaption {
bottom: 0;
opacity: 1;
}
#media only screen and (max-width: 500px) {
center {
width: 250px;
margin: 0 auto;
}
}
#media only screen and (max-width: 250px) {
center {
width: 110px;
margin: 0 auto;
}
figure.menu figcaption {
bottom: 0;
opacity: 1;
}
}
<center>
<figure class="menu">
<a href="#">
<img src="http://placehold.it/70x70">
<figcaption>Doctors</figcaption>
</a>
</figure>
<figure class="menu">
<a href="#">
<img src="http://placehold.it/70x70">
<figcaption>Labs</figcaption>
</a>
</figure>
<figure class="menu">
<a href="#">
<img src="http://placehold.it/70x70">
<figcaption>Gym</figcaption>
</a>
</figure>
<figure class="menu">
<a href="#">
<img src="http://placehold.it/70x70">
<figcaption>Spa</figcaption>
</a>
</figure>
</center>
Mousing over one of the images/links will make the name slide in.
To get rid of the underlines of a link, all you will need to do in your CSS file is:
a {
text-decoration: none; // removes the underline for all links
color: inherit; // removes the blue color and sets the parents color for all links
}
To get a image and text horizontally aligned with each other, what I would do at least would be to create a few lists that you align horizontally and add some style to:
.horizontal-view ul {
list-style-type: none;
}
.horizontal-view li {
margin-left: auto;
margin-right: auto;
display: inline-table;
}
.picture {
margin-right: 10px;
}
<ul class="horizontal-view">
<li>
<img src="https://placehold.it/70x70" class="picture" />
</li>
<li>My First Image Caption</li>
</ul>
<ul class="horizontal-view">
<li>
<img src="https://placehold.it/70x70" class="picture" />
</li>
<li>My Second Image Caption</li>
</ul>
<ul class="horizontal-view">
<li>
<img src="https://placehold.it/70x70" class="picture" />
</li>
<li>My Third Image Caption</li>
</ul>

Removing space between menu and image

Does anyone know how I can remove the space between the top of my menu and the bottom of the image on top of the page. I tried to do it with margin and padding. But that didn't work.
This is a picture of the result I get now
#charset "UTF-8";
body {
background-color: #ADF1F5;
}
html,
body {
margin: 0;
padding: 0;
}
#Anouk {
text-align: center;
margin: 0 auto;
padding: 0;
}
#header {
height: 80px;
background: #000000;
}
li {
display: block;
float: left;
}
li a {
color: #FFFFFF;
height: 80px;
}
#contact {
float: right;
}
<div id="Anouk">
<img src="logo/Hout.png" width="1000px" alt="Logo" />
</div>
<div id="header">
<div id="menu">
<!--Home-->
<li id="home">
<a href="index.html">
<img src="Iconen/Home.png" height="80px" alt="home" onmouseover="this.src='Iconen/Home2.png'" onmouseout="this.src='Iconen/Home.png'" />
</a>
</li>
<!--Over Mij-->
<li id="over">
<a href="over.html">
<img src="Iconen/Over.png" height="80px" alt="home" onmouseover="this.src='Iconen/Over2.png'" onmouseout="this.src='Iconen/Over.png'" />
</a>
</li>
<!--Portfolio-->
<li id="portfolio">
<a href="portfolio.html">
<img src="Iconen/Portfolio.png" height="80px" alt="home" onmouseover="this.src='Iconen/Portfolio2.png'" onmouseout="this.src='Iconen/Portfolio.png'" />
</a>
</li>
<!--Contact-->
<li id="contact">
<a href="contact.html">
<img src="Iconen/Contact.png" height="80px" alt="home" onmouseover="this.src='Iconen/Contact2.png'" onmouseout="this.src='Iconen/Contact.png'" />
</a>
</li>
</div>
</div>
Try to add display:block to your top most image.
#Anouk img{
display: block;
}
Here is a solution: https://jsfiddle.net/egjbmp1u/
For your #header style you need to add:
position: relative;
float: left;
width: 100%;
Also, #Anouk style should look like this:
#Anouk {
display: flex;
text-align: center;
padding: 0;
}
#Anouk img {
margin: 0 auto;
}

show an element that's not a child of the anchor with pure css

I want to trigger the element to display the hidden elements on hover
HTML
<div class="contents">
<aside>
<section class="tumb">
<a class="placeHoldTumb" href="#"><img src="http://placehold.it/100x100">
<a class="placeHoldTumb" href="#"><img src="http://placehold.it/100x100">
</section>
</aside>
<div class="hidden">
<a href="#" class="one" ><img src="http://placehold.it/1000x1000/bada55" width="500px" ></a>
<a href="#" class="two" ><img src="http://placehold.it/1000x1000/bada55" width="500px" ></a>
</div>
<a href="#" class="background" ><img src="http://placehold.it/1000x1000/000000/bada55" width="500px" /></a>
</div><!-- end contents -->
CSS
aside {
z-index: 100;
background: rgba(0, 182, 173, 0.9);
width: 230px;
position: absolute; }
aside .tumb img {
margin: 5px; position: relative; }
.contents img {
position: absolute; }
.hidden img { opacity: 0; }
.tumb a:hover ~ .hidden img {
opacity: 1;
filter:alpha(opacity=100); /*For IE8*/ }
demo here: http://codepen.io/mvaneijgen/pen/ELBAg
try the below CSS in your code... it will work
.hidden{
opacity:0;
filter:alpha(opacity=0);
}
.contents:hover .hidden{
opacity: 1;
filter:alpha(opacity=100);
}
I have tried your code in Fiddle... refer this link : http://jsfiddle.net/NUBkp/14/