how to create a fullscreen overlay menu? - html

I am trying to make a full-screen menu with two sides, one side has a list of items; Home, Services, Portfolio and the other side will show an image on item hover. For example, if mouse hover on Services, a new image shows up and so.
This is what I need:
But, this is what I have so far:
Another example of what I'm trying to do is this website
Any help pleaseee??
Thanks,
PS: Hide the image in mobile.
.overlay {
height: 100%;
width: 0;
position: fixed;
z-index: 1;
top: 0;
left: 0;
background-color: $dkgreen;
background-color: $dkgreen;
overflow-x: hidden;
transition: 0.5s;
}
.overlay-content {
position: relative;
/* top: 25%;*/
width: 100%;
text-align: center;
* margin-top: 30px;
*/
}
.overlay a {
padding: 8px;
text-decoration: none;
font-size: 36px;
color: #818181;
display: block;
transition: 0.3s;
}
.overlay a:hover,
.overlay a:focus {
color: #f1f1f1;
}
.overlay .closebtn {
position: absolute;
top: 20px;
right: 45px;
font-size: 60px;
z-index: 1;
}
#media screen and (max-height: 450px) {
.overlay a {
font-size: 20px
}
.overlay .closebtn {
font-size: 40px;
top: 15px;
right: 35px;
}
}
<nav class=" navbar navbar-dark fixed-top">
<div class="container">
<a class="navbar-brand" href="#"><img src="./img/maduro-logo.png" class="img-fluid" width="115" /></a>
<button class="navbar-toggler custom-toggler" type="button" onclick="openNav()">
<span class="navbar-toggler-icon"></span>
</button>
<div id="myNav" class="overlay">
<div class="row overlay-content">
<a href="javascript:void(0)" class="closebtn" onclick="closeNav()">×
</a>
<div class="col-sm-5">
<a style="color: #fff;" id="" class="" href="index.php">Home</a>
<a style="color: #fff;" id="" class="" href="services.php">Services</a>
<a style="color: #fff;" id="" class="" href="portfolio.php">Portfolio</a>
<a style="color: #fff;" id="" class="" href="clients.php">Clients</a>
<a style="color: #fff;" id="" class="" href="contact.php">Contact</a>
</div>
<div class="col-sm-7">
<img class="img-fluid" src="img/a.jpg">
</div>
</div>
</div>
Edit:

$('#home').hover(function() {
$('.change-img').css({
"background-image": "url('https://www.ryanhomes.com/rh-community-gallery-NewAspectRatio/7ac519ed-9b29-47b0-a489-ded2da8b770f/db/7ac519ed-9b29-47b0-a489-ded2da8b770f.jpg')"
});
});
$('#services').hover(function() {
$('.change-img').css({
"background-image": "url('https://www.starwebcreations.com/new_images/services.jpg')"
});
});
$('#portfolio').hover(function() {
$('.change-img').css({
"background-image": "url('https://www.ryanhomes.com/rh-community-gallery-NewAspectRatio/7ac519ed-9b29-47b0-a489-ded2da8b770f/db/7ac519ed-9b29-47b0-a489-ded2da8b770f.jpg')"
});
});
$('#clients').hover(function() {
$('.change-img').css({
"background-image": "url('https://www.starwebcreations.com/new_images/services.jpg')"
});
});
$('#contact').hover(function() {
$('.change-img').css({
"background-image": "url('https://www.ryanhomes.com/rh-community-gallery-NewAspectRatio/7ac519ed-9b29-47b0-a489-ded2da8b770f/db/7ac519ed-9b29-47b0-a489-ded2da8b770f.jpg')"
});
});
.side-bar {
width: 50vw;
background-color: #ddd;
height: 100vh;
position: fixed;
top: 0;
left: 0;
bottom: 0;
}
.side-bar>ul {
list-style-type: none;
}
.side-bar>ul>li {
text-align: center;
padding: 15px 0;
cursor: pointer;
}
.img-sec {
width: 50vw;
background-color: #333;
height: 100vh;
position: fixed;
top: 0;
right: 0;
bottom: 0;
}
.change-img {
width: 100%;
max-height: 100%;
background-size: cover;
background-position: center;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div>
<div class="side-bar">
<ul>
<li id="home">Home</li>
<li id="services">Services</li>
<li id="portfolio">Portfolio</li>
<li id="clients">Clients</li>
<li id="contact">Contacts</li>
</ul>
</div>
<div class="img-sec">
<div class="change-img"></div>
</div>
</div>

Related

CSS Pseudo Classes not active ? ( display: block and animation not working)? [duplicate]

This question already has answers here:
Transitions on the CSS display property
(37 answers)
Closed 11 months ago.
I am newbie with html css and here is my problem.
I want to hide a block, then when I use an animation, it will show this block.
I refer a website and it tell me that I should use a CSS Pseudo Classes.
I tried it and at my 1st animation, I successfully to display the image.
Here is the code of the 1st animation
html code :
<div class="header__qr">
<img src="./assets/img/QRcode.png" alt="QR code" class="header__qr-img">
<div class="header__qr-apps">
<a href="" class="header__qr-link">
<img src="./assets/img/Googleplay.png" alt="Google play" class="header__qr-download-img">
</a>
<a href="" class="header__qr-link">
<img src="./assets/img/apple store.png" alt="App store" class="header__qr-download-img">
</a>
</div>
</div>
css code :
.header__qr {
width: 190px;
position: absolute;
left: 0;
top: 110%;
padding: 8px;
display: none;
animation: fadeIn ease-in 1s;
}
.header__qr::before {
position: absolute;
left: 0;
top: -16px;
width: 100%;
height: 20px;
content: "";
display: block;
}
and here is my 2nd animation code
<div class="header__notify">
<div class="header__img">
<img src="./assets/img/xemthongbao.png" alt="xemthongbao" class="header__notify-img">
</div>
<div class="header__notify-info">
<span class="header__notify-name">Đăng nhập để xem Thông báo</span>
</div>
<div class="register-info">
<div class="child register-register">Đăng ký</div>
<div class="child register-login">Đăng nhập</div>
</div>
</div>
css code is here
.header__notify {
background-color: white;
width: 400px;
position: absolute;
left: 0;
top: 110%;
padding: 20px;
display: none;
animation: fadeIn ease-in 1s;
}
.header__notify::before {
position: absolute;
left: 0;
top: -16px;
width: 100%;
height: 20px;
content: "";
display: block;
}
As you can see, the second code is very same as the first code, and when I delete the display:none, it display the image ? So I think that the CSS Pseudo Classes must be actived ? But it does not active as I wish.
Here is all of my code
https://github.com/anhquanjp/bai110headernotification
Could you please give me some ideas for this problem ? Thank you very much for your time.
Because that animation fadeIn set opacity 0 to 1 and header__notify has display none properity.
Add .header__navbar-item:hover .header__notify { display: block; } to your main Thong bao dropdown will work.
.header {
height: 120px;
background-image: linear-gradient(0, #fe6433, #f7482e);
}
.header__navbar {
display: flex;
justify-content: space-between;
}
.header__navbar-list {
list-style: none;
padding-left: 0;
margin-top: 14px;
}
.header__navbar-item {
margin: 0 8px;
position: relative;
min-height: 26px;
}
.header__navbar-item,
.header__navbar-item-link {
display: inline-block;
font-size: 1.3rem;
color: var(--white-color);
text-decoration: none;
font-weight: 3;
}
.header__navbar-item,
.header__navbar-item-link,
.header__navbar-icon-link {
display: inline-flex;
align-items: center;
}
.header__navbar-item:hover,
.header__navbar-icon-link:hover,
.header__navbar-item-link:hover {
color: rgba(255, 255, 255, 0.7);
cursor: pointer;
}
.header__navbar-item--bold {
font-weight: 500;
}
.header__navbar-item--separate::after {
content: "";
display: block;
position: absolute;
border-left: 1px solid #ffffff;
height: 16px;
right: -9px;
top: 50%;
transform: translateY(-50%);
}
.header__navbar-icon-link {
color: var(--white-color);
text-decoration: none;
}
.header__navbar-icon {
font-size: 1.8rem;
margin: 0 4px;
}
.header__navbar-title--no-pointer {
cursor: text;
color: var(--white-color);
}
.header__qr {
width: 190px;
position: absolute;
left: 0;
top: 110%;
padding: 8px;
display: none;
animation: fadeIn ease-in 1s;
}
.header__qr::before {
position: absolute;
left: 0;
top: -16px;
width: 100%;
height: 20px;
content: "";
display: block;
}
.header__navbar-item--has-qr:hover .header__qr {
display: block;
}
.header__qr-img {
}
.header__qr-apps {
display: flex;
justify-content: space-between;
}
.header__qr-download-img {
height: 18px;
}
.header__notify {
background-color: white;
width: 400px;
position: absolute;
left: 0;
top: 110%;
padding: 20px;
display: none;
animation: fadeIn ease-in 1s;
}
.header__notify::before {
position: absolute;
left: 0;
top: -16px;
width: 100%;
height: 20px;
content: "";
display: block;
}
.header__navbar-item:hover .header__notify {
display: block;
}
.header__img {
display: flex;
align-items: center;
justify-content: center;
height: 300px;
}
.header__notify-img {
width: 100px;
height: 100px;
display: block;
margin-left: auto;
margin-right: auto;
}
.header__notify-name {
color: black;
margin-top: 100px;
}
.register-info {
display: flex;
align-items: center;
justify-content: center;
}
.header__notify-info {
font-size: 14px;
font-weight: bold;
text-align: center;
}
.register-login,
.register-register {
font-size: 14px;
font-weight: bold;
background-color: rgb(248, 245, 245);
color: black;
float: left;
flex: 1;
text-align: center;
height: 30px;
width: 300px;
}
.register-login:hover,
.register-register:hover {
color: red;
background-color: rgb(238, 227, 227);
height: 30px;
}
:root {
--white-color: #fff;
--black-color: #000;
--text-color: #333;
}
* {
box-sizing: inherit;
}
html {
font-size: 100%;
line-height: 1.6rem;
font-family: "Roboto", sans-serif;
box-sizing: border-box;
}
.grid {
width: 1200px;
max-width: 100%;
margin: 0 auto;
}
.grid__full-width {
width: 100%;
}
.grid__row {
display: flex;
flex-wrap: wrap;
}
#keyframes fadeIn {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
#keyframes fadeInNotify {
from {
display: none;
}
to {
display: unset;
}
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/8.0.1/normalize.min.css">
<link rel="stylesheet" href="./assets/css/base.css">
<link rel="stylesheet" href="./assets/css/main.css">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link rel="stylesheet" href="assets/fonts/fontawesome-free-6.1.0-web/css/all.min.css">
<link href="https://fonts.googleapis.com/css2?family=Roboto:ital,wght#0,100;0,300;1,100&display=swap" rel="stylesheet">
</head>
<body>
<!-- Block element modifier -->
<div class="app">
<header class="header">
<div class="grid">
<nav class="header__navbar">
<ul class="header__navbar-list">
<li class="header__navbar-item header__navbar-item--separate">Kênh Người Bán</li>
<li class="header__navbar-item header__navbar-item--separate">Trở thành Người bán Shopee</li>
<li class="header__navbar-item header__navbar-item--has-qr header__navbar-item--separate">Tải ứng dụng
<div class="header__qr">
<img src="./assets/img/QRcode.png" alt="QR code" class="header__qr-img">
<div class="header__qr-apps">
<a href="" class="header__qr-link">
<img src="./assets/img/Googleplay.png" alt="Google play" class="header__qr-download-img">
</a>
<a href="" class="header__qr-link">
<img src="./assets/img/apple store.png" alt="App store" class="header__qr-download-img">
</a>
</div>
</div>
</li>
<li class="header__navbar-item">
<span class="header__navbar-title--no-pointer">Kết nối</span>
<a href="" class="header__navbar-icon-link">
<i class="header__navbar-icon fa-brands fa-facebook-square"></i>
</a>
<a href="" class="header__navbar-icon-link">
<i class="header__navbar-icon fa-brands fa-instagram"></i>
</a>
</li>
</ul>
<ul class="header__navbar-list">
<li class="header__navbar-item">
<a href="" class="header__navbar-item-link">
<i class="header__navbar-icon fa-solid fa-bell"></i> Thong bao
<div class="header__notify">
<div class="header__img">
<img src="./assets/img/xemthongbao.png" alt="xemthongbao" class="header__notify-img">
</div>
<div class="header__notify-info">
<span class="header__notify-name">Đăng nhập để xem Thông báo</span>
</div>
<div class="register-info">
<div class="child register-register">Đăng ký</div>
<div class="child register-login">Đăng nhập</div>
</div>
</div>
</a>
</li>
<li class="header__navbar-item">
<a href="" class="header__navbar-item-link">
<i class="header__navbar-icon fa-solid fa-circle-question"></i> Ho tro</a>
</li>
<li class="header__navbar-item header__navbar-item--bold header__navbar-item--separate">Tro giup</li>
<li class="header__navbar-item header__navbar-item--bold">Dang nhap</li>
</ul>
</nav>
</div>
</header>
<div class="container">
</div>
<footer class="footer">
</footer>
</div>
</body>
</html>

My bootstrap modal is open by default / broken

I am an inexperienced developer who is having some issues with a bootstrap modal that should slide down the full width of the page when clicking on the 'Info' button. It was working fine until a few days ago but i'm not sure what has caused this issue. I am in the process of learning git so in future I can revert back to previous versions.
Here is the site: deannoble.com.au
This is the button that should open up the modal:
<span onclick="openNav()">
<button type="button" data-toggle="modal" data-target=".bd-example-modal-xl">
<a class="btn btn-primary" class="closebtn" onclick="closeNav()" href="../website/index.html" href="javascript:void(0)" data-toggle="modal" data-target=".bd-example-modal-xl">Info</a>
</button>
</span>
This is the content within the modal:
<div class="container over" href="javascript:void(0)" class="closebtn" onclick="closeNav()">
<div id="myNav" class="overlay">
×
<div class="overlay-content">
<div class="row d-flex justify-content-center">
<div class="col-lg-8">
<h2 class="overlay-text">Hello 👋 </h2>
<h2 class="overlay-text">I'm a Melbourne-based UX/UI designer and also a pretty decent amateur baker.</h2>
</div>
</div>
</div>
</div>
</div>
And this is the CSS
.overlay {
height: 0%;
width: 100%;
position: fixed;
z-index: 1;
left: 0;
top: 0;
background-color: rgba(205, 178, 255, 0.95);
overflow-y: hidden;
transition: 1.2s;
}
.overlay-content {
position: relative;
top: 25%;
width: 100%;
text-align: center;
}
.overlay a {
text-decoration: none;
font-size: 2rem;
color: #4e3380;
display: block;
transition: 0.3s;
}
.overlay a:hover,
.overlay a:focus {
color: black;
}
.overlay .closebtn {
position: absolute;
top: 1rem;
font-size: 2rem;
}
#media screen and (max-height: 450px) {
.overlay {
overflow-y: auto;
}
.overlay a {
font-size: 20px;
}
.overlay .closebtn {
font-size: 2rem;
top: 1rem;
right: 2rem;
}
}
h2.overlay-text {
color: #4e3380;
text-align: left;
font-weight: 600;
letter-spacing: 0.02em;
margin-bottom: 1rem;
}```
Any help would be great.
The problem is your cache, just delete it and all work.

HTML elements overlapping

So I'm using hero image for my website which is 100 vh high. Now the image is positioned absolutely, so I could position other elements like logo, nav and text on the image relatively to it. After this section, I want to start new section with new image and other text, but once I start new row, column and try to put new image with h1 text, it's hiding behind earlier image. What I mean is that I want a new section with new image and <h1> text appear under the hero image and not overlap it or hide under it as it is now hiding. It's not floated or anything, my floats are cleared, so I don't get it why is this hapenning.
Here is some codepen so you would understand what is hapenning.
<div class="container-fluid clearfix">
<div class="row">
<div class="col-lg-12">
<div class="hero_img">
<img class="logo" src="assets/logo.png"></img>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target=".collapse">
☰
</button>
<div class="collapse">
<div class="col-xs-12">
<ul class="nav">
<li class="nav-item">
<a class="nav-link" href="#">Lorem</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Lorem</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Lorem</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Lorem</a>
</li>
</ul>
</div>
</div>
<div class="black_box clearfix"><h1>Kolding Bike Marathon</h1></div>
<div class="black_box_sub clearfix"><p>Bring activity to your life again</p></div>
<button type="button" class="btn btn-outline-secondary">Register now</button>
<button type="button" class="btn btn-success">Learn more</button>
</div>
</div>
</div>
</div>
</div>
<div class="section_one">
<h1>heyyyyy</h1>
</div>
.hero_img {
background-image: url("assets/hero.jpg");
width: auto;
height: 100vh;
background-size: cover;
position: absolute;
top: 0;
left: 0;
z-index: 999;
overflow: hidden;
clear: both;
}
.hero_img {
width: 100%;
height: 100vh;
position: absolute;
top: 0;
}
.logo {
position: relative;
left: 20px;
top: 20px;
z-index: 1002;
width: 5%;
min-width: 50px;
}
.nav {
position: relative;
top: 0;
z-index: 1000;
margin-top: 20px;
/*margin-right: 15px;*/
padding: 20px;
/*float: right;*/
width: auto;
flex-direction: column;
background: #555;
/*width: 100%;*/
filter: opacity(0.93);
}
a {
text-decoration: none;
color: white;
display: block;
border-bottom: 1px solid #444;
}
a:hover {
color: #999;
}
.nav-item {
display: block;
}
.navbar-toggler {
/*float: right;*/
display: flex;
justify-content: right;
position: relative;
z-index: 1000;
margin-top: 15px;
margin-right: 15px;
color: white;
float: right;
}
.black_box {
position: relative;
width: 45%;
min-width: 400px;
text-align: center;
z-index: 1000;
background: black;
margin-top: 10%;
padding: 10px 30px;
clear: both;
}
.black_box h1 {
color: white;
/*font-family: 'PT Sans', sans-serif;*/
font-family: 'Montserrat', sans-serif;
font-weight: 600;
letter-spacing: 1.5px;
}
.black_box_sub {
position: relative;
width: 30%;
min-width: 310px;
text-align: center;
z-index: 1001;
background: black;
margin-top: 2%;
clear: both;
margin-left: 90px;
}
.black_box_sub p {
color: white;
padding: 5px 25px;
font-family: 'Montserrat', sans-serif;
text-transform: uppercase;
padding-top: 10px;
padding-bottom: 0px;
}
Codepen: http://codepen.io/Limpuls/pen/NpbwYp
There are multiple items to clean up in the code, but to keep the images from overlapping you can remove both entries of position: absolute; from the .hero_img class.
After that, remove the padding left and right from all of the media queries of container-fluid. This may affect and other padding that was needed in that container but would be a quick path to do what you are asking.

Can't put any div's under image slider

I can't position div's under my image slider. They all go above the slider as if the slider isn't within the container. Whenever I try to put another div under the wrapper the position is completely off. Is it because I have the slider in a wrapper div?
<body>
<div class="container" id="container-1">
<!--Navigation Begin-->
<div class="navbar navbar-inverse navbar-fixed-top" id="custom-nav">
<div class="container">
<!-- .btn-navbar is used as the toggle for collapsed navbar content -->
<button class="navbar-toggle" data-target=".navbar-responsive-collapse" data-toggle="collapse" type="button">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="/"><img src="../Images/nav-logo.png" alt="Breakday Charters Logo"></a>
<div class="nav-collapse collapse navbar-responsive-collapse">
<ul class="nav navbar-nav">
<li>
Home
</li>
<li>About</li>
<li>Booking</li>
<li>Report</li>
<li>Gallery</li>
<li>Contact</li>
</ul>
<ul class="nav navbar-nav pull-right">
<h3 id="number-head">Get Hooked</h3>
<p id="nav-number">(252)xxx-xxxx</p>
<li><img src="../Images/hook.png" alt="hook" id="nav-hook"/></li>
</ul>
</ul><!-- end nav pull-right -->
</div><!-- end nav-collapse -->
</div><!-- end container -->
</div><!-- end navbar -->
<!--================Carousel===============-->
<div id="wrapper">
<div id="carousel">
<img src="../Images/Carousel/breakday-boat-lrg.png"alt="Breakday Charters Boat" width="990" height="450" class="img-responsive" />
<img src="../Images/Carousel/turtle.png" alt="turtle" width="990" height="450" class="img-responsive"/>
<img src="../Images/Carousel/justin-and-fish.png" alt="Captain Justin" width="990" height="450" class="img-responsive" />
<img src="../Images/Carousel/shark.png" alt="shark" width="990" height="450" class="img-responsive" />
</div>
<div id="pager"></div>
</div><!--wrapper div end-->
</div><!--container-->
CSS:
html, body {
height: 100%;
padding: 0;
margin: 0;
}
/*Navigation*/
#custom-nav {
min-height:85px;
background: #FFF;
border-bottom:#0e76bc medium solid;
}
.nav.navbar-nav li a {
color: #0E76BC;
margin-top:25px;
font-size:15px;
}
.nav.navbar-nav li a:hover {
color: #494238;
}
.nav.navbar-nav.pull-right li #nav-hook {
position: absolute;
z-index: 1031;
top: -40px;
}
.nav.navbar-nav.pull-right #nav-number {
font-size: 16px;
color: #333;
font-weight: bold;
}
.nav.navbar-nav.pull-right #number-head {
font-weight: bold;
color: #0e76bc;
}
.nav.navbar-nav.pull-right {
margin-top: 5px;
}
/* --------------------------------------
Carousel
-------------------------------------- */
#wrapper {
background-color: #fff;
width: 100%;
height: 450px;
margin-top: -225px;
overflow: hidden;
position: absolute;
top: 40%;
left: 0;
}
#carousel img {
display: block;
float: left;
clear:right;
}
#prev, #next {
background-color: rgba(255, 255, 255, 0.7);
display: block;
height: 450px;
width: 50%;
top: 0;
position: absolute;
}
#prev:hover, #next:hover {
background-color: #fff;
background-color: rgba(255, 255, 255, 0.8);
}
#prev {
left: -495px;
}
#next {
right: -495px;
}
#pager {
margin-left: -470px;
position: absolute;
left: 50%;
bottom: 10px;
}
#pager a {
border: 2px solid #fff;
border-radius: 10px;
display: inline-block;
width: 10px;
height: 10px;
margin: 0 5px 0 0;
}
#pager a:hover {
background-color: rgba(255, 255, 255, 0.5);
}
#pager a span {
display: none;
}
#pager a.selected {
background-color: #fff;
}
For slider banner you can try this
html
<div class="banner">
<div class="bannerslider">
<div class="slidertxt">
<div class="slidernumber">
<div id="nav">
<ul>
<li><a class="active" href="#" onclick="goto('#1', this); return false">1</a></li>
<li>2</li>
<li>3</li>
<li>4</li>
<li>5</li>
</ul>
</div>
</div>
</div>
</div>
<div class="bannerimage">
<div id="contentt">
<div class="contentbox-wrapper">
<div id="1" class="contentbox">
<p> <img border="0" src="../Images/Carousel/breakday-boat-lrg.png" title="Haani"> </p>
</div>
<div id="2" class="contentbox">
<p> <img border="0" src="../Images/Carousel/breakday-boat-lrg.png"> </p>
</div>
<div id="3" class="contentbox">
<p> <img border="0" src="../Images/Carousel/breakday-boat-lrg.png"> </p>
</div>
<div id="4" class="contentbox">
<p> <img border="0" src="../Images/Carousel/breakday-boat-lrg.png"> </p>
</div>
<div id="5" class="contentbox">
<p> <img border="0" src="../Images/Carousel/breakday-boat-lrg.png"> </p>
</div>
</div>
</div>
</div>
</div>
css :
.banner {
width: 900px;
height: 357px;
margin:0;
float: left;
}
.bannerslider {
width: 500px;
position: absolute;
height: 351px;
float: left;
z-index: 80;
background-size: 350px 351px;
margin: 0 0 0 2px;
}
.slidertxt {
font-family: 'AUdimat-Regular';
font-weight: normal;
text-shadow: 0 2px 1px #000000;
color: #fbfbfb;
font-size: 14px;
width: 500px;
margin: 60px 0 0 30px;
position: absolute;
}
#contentt {
overflow: hidden;
}
.contentbox-wrapper {
position: relative;
left: 0;
width: 5000px;
height: 100%;
}
.contentbox {
width: 975px;
height: 100%;
float: left;
}
.slidertxt p {
font-family: 'AUdimat-Bold';
color: #fbfbfb;
font-size: 30px;
width: 960px;
}
.slidernumber {
height: 30px;
margin-top: -40px;
position: relative;
z-index: 10000;
}
#nav {
margin-top: 0;
}
#nav ul li {
display: inline;
}
.slidernumber a {
color: #fbfbfb;
text-decoration: none;
font-size: 13px;
font-family: 'AUdimat-Regular';
padding: 0 5px 0 5px;
margin: 5px 5px 0 10px;
display: inline;
float: left;
}
#nav a.active {
background: #fbfbfb;
border: 1px solid #fbfbfb;
border-radius: 10px;
color: #8a0338;
}
.bannerimage {
width: 975px;
height: 350px;
z-index: 0;
margin: 1px 2px 0 5px;
float: right;
}
JS :
function goto(id, t){
$(".contentbox-wrapper").animate({"left": -($(id).position().left)}, 600);
$('#nav a').removeClass('active');
$(t).addClass('active');
}
you can also try slider banner

How to show text on image when hovering?

I'm trying to show a description when hovering over an image. I've already done it in a less than desirable way, using image sprites and hovers here: I want it to look exactly like how I have it, but using real text instead of an image.
I've tried a few different things but I can't seem to figure out how to do it. I'm trying to do it using HTML and CSS only, but I'm not sure if that's possible.
Feel free to poke around in my code, I'll paste what I think is relavent here.
HTML
div#projectlist {
width: 770px;
margin: 0 auto;
margin-top: 20px;
margin-bottom: 40px;
}
div#buzzbutton {
display: block;
float: left;
margin: 2px;
background: url(content/assets/thumbnails/design/buzz_sprite.jpg) 0 0px no-repeat;
width: 150px;
height: 150px;
}
div#buzzbutton:hover {
background: url(content/assets/thumbnails/design/buzz_sprite.jpg);
width: 150px;
height: 150px;
background-position: 0 -150px;
}
div#slinksterbutton {
display: block;
float: left;
background: url(content/assets/thumbnails/design/slinkster_sprite.jpg) 0 0px no-repeat;
width: 150px;
height: 150px;
margin: 2px;
}
div#slinksterbutton:hover {
background: url(content/assets/thumbnails/design/slinkster_sprite.jpg);
width: 150px;
height: 150px;
background-position: 0 -150px;
}
<div id="projectlist">
<div id="buzzbutton">
<img src="content/assets/thumbnails/transparent_150x150.png" alt="" />
</div>
<div id="slinksterbutton">
<img src="content/assets/thumbnails/transparent_150x150.png" alt="" />
</div>
</div>
It's simple. Wrap the image and the "appear on hover" description in a div with the same dimensions of the image. Then, with some CSS, order the description to appear while hovering that div.
/* quick reset */
* {
margin: 0;
padding: 0;
border: 0;
}
/* relevant styles */
.img__wrap {
position: relative;
height: 200px;
width: 257px;
}
.img__description {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
background: rgba(29, 106, 154, 0.72);
color: #fff;
visibility: hidden;
opacity: 0;
/* transition effect. not necessary */
transition: opacity .2s, visibility .2s;
}
.img__wrap:hover .img__description {
visibility: visible;
opacity: 1;
}
<div class="img__wrap">
<img class="img__img" src="http://placehold.it/257x200.jpg" />
<p class="img__description">This image looks super neat.</p>
</div>
A nice fiddle: https://jsfiddle.net/govdqd8y/
EDIT:
There's another option if you don't want to explicitly set the height of the <img> on the wrapping <div>, and that is simply setting the <div>'s display to inline-block. (Keep in mind, though, that it won't look good if the image fails to load.)
If you choose this option, you'll notice that there'll be a slight spacing between the <img> and the bottom of the wrapping <div>. That's because of the <img>'s default vertical-align value of baseline. If you set it to bottom it will disappear.
Here's a fiddle using this option: https://jsfiddle.net/joplomacedo/5cL31o0g/
In your HTML, try and put the text that you want to come up in the title part of the code:
<a href="buzz.html" title="buzz hover text">
You can also do the same for the alt text of your image.
You can also use the title attribute in your image tag
<img src="content/assets/thumbnails/transparent_150x150.png" alt="" title="hover text" />
This is what I use to make the text appear on hover:
* {
box-sizing: border-box
}
div {
position: relative;
top: 0px;
left: 0px;
width: 400px;
height: 400px;
border-radius: 50%;
overflow: hidden;
text-align: center
}
img {
width: 400px;
height: 400px;
position: absolute;
border-radius: 50%
}
img:hover {
opacity: 0;
transition:opacity 2s;
}
heading {
line-height: 40px;
font-weight: bold;
font-family: "Trebuchet MS";
text-align: center;
position: absolute;
display: block
}
div p {
z-index: -1;
width: 420px;
line-height: 20px;
display: inline-block;
padding: 200px 0px;
vertical-align: middle;
font-family: "Trebuchet MS";
height: 450px
}
<div>
<img src="https://68.media.tumblr.com/20b34e8d12d4230f9b362d7feb148c57/tumblr_oiwytz4dh41tf8vylo1_1280.png">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing <br>elit. Reiciendis temporibus iure dolores aspernatur excepturi <br> corporis nihil in suscipit, repudiandae. Totam.
</p>
</div>
.container {
position: relative;
width: 50%;
}
.image {
display: block;
width: 100%;
height: auto;
}
.overlay {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
height: 100%;
width: 100%;
opacity: 0;
transition: .5s ease;
background-color: #008CBA;
}
.container:hover .overlay {
opacity: 1;
}
.text {
color: white;
font-size: 20px;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
}
<!DOCTYPE html>
<html>
<head></head>
<body>
<div class="container">
<img src="http://lorempixel.com/500/500/" alt="Avatar" class="image">
<div class="overlay">
<div class="text">Hello World</div>
</div>
</div>
</body>
</html>
Reference Link W3schools with multiple styles
HTML
<img id="close" className="fa fa-close" src="" alt="" title="Close Me" />
CSS
#close[title]:hover:after {
color: red;
content: attr(title);
position: absolute;
left: 50px;
}
I saw a lot of people use an image tag. I prefer to use a background image because I can manipulate it. For example, I can:
Add smoother transitions
save time not having to crop images by using the "background-size: cover;" property.
The HTML/CSS:
.overlay-box {
background-color: #f5f5f5;
height: 100%;
background-repeat: no-repeat;
background-size: cover;
}
.overlay-box:hover .desc,
.overlay-box:focus .desc {
opacity: 1;
}
/* opacity 0.01 for accessibility */
/* adjust the styles like height,padding to match your design*/
.overlay-box .desc {
opacity: 0.01;
min-height: 355px;
font-size: 1rem;
height: 100%;
padding: 30px 25px 20px;
transition: all 0.3s ease;
background: rgba(0, 0, 0, 0.7);
color: #fff;
}
<div class="overlay-box" style="background-image: url('https://via.placeholder.com/768x768');">
<div class="desc">
<p>Place your text here</p>
<ul>
<li>lorem ipsum dolor</li>
<li>lorem lipsum</li>
<li>lorem</li>
</ul>
</div>
</div>
<!DOCTYPE html><html lang='en' class=''>
<head><script src='//production-assets.codepen.io/assets/editor/live/console_runner-079c09a0e3b9ff743e39ee2d5637b9216b3545af0de366d4b9aad9dc87e26bfd.js'></script><script src='//production-assets.codepen.io/assets/editor/live/events_runner-73716630c22bbc8cff4bd0f07b135f00a0bdc5d14629260c3ec49e5606f98fdd.js'></script><script src='//production-assets.codepen.io/assets/editor/live/css_live_reload_init-2c0dc5167d60a5af3ee189d570b1835129687ea2a61bee3513dee3a50c115a77.js'></script><meta charset='UTF-8'><meta name="robots" content="noindex"><link rel="shortcut icon" type="image/x-icon" href="//production-assets.codepen.io/assets/favicon/favicon-8ea04875e70c4b0bb41da869e81236e54394d63638a1ef12fa558a4a835f1164.ico" /><link rel="mask-icon" type="" href="//production-assets.codepen.io/assets/favicon/logo-pin-f2d2b6d2c61838f7e76325261b7195c27224080bc099486ddd6dccb469b8e8e6.svg" color="#111" /><link rel="canonical" href="https://codepen.io/nelsonleite/pen/RaGwba?depth=everything&order=popularity&page=4&q=product&show_forks=false" />
<link href='https://fonts.googleapis.com/css?family=Raleway' rel='stylesheet' type='text/css'>
<link rel='stylesheet prefetch' href='https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css'>
<style class="cp-pen-styles">.product-description {
transform: translate3d(0, 0, 0);
transform-style: preserve-3d;
perspective: 1000;
backface-visibility: hidden;
}
body {
color: #212121;
}
.container {
padding-top: 25px;
padding-bottom: 25px;
}
img {
max-width: 100%;
}
hr {
border-color: #e5e5e5;
margin: 15px 0;
}
.secondary-text {
color: #b6b6b6;
}
.list-inline {
margin: 0;
}
.list-inline li {
padding: 0;
}
.card-wrapper {
position: relative;
width: 100%;
height: 390px;
border: 1px solid #e5e5e5;
border-bottom-width: 2px;
overflow: hidden;
margin-bottom: 30px;
}
.card-wrapper:after {
content: "";
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
opacity: 0;
box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
transition: opacity 0.6s cubic-bezier(0.165, 0.84, 0.44, 1);
}
.card-wrapper:hover:after {
opacity: 1;
}
.card-wrapper:hover .image-holder:before {
opacity: .75;
}
.card-wrapper:hover .image-holder:after {
opacity: 1;
transform: translate(-50%, -50%);
}
.card-wrapper:hover .image-holder--original {
transform: translateY(-15px);
}
.card-wrapper:hover .product-description {
height: 205px;
}
#media (min-width: 768px) {
.card-wrapper:hover .product-description {
height: 185px;
}
}
.image-holder {
display: block;
position: relative;
width: 100%;
height: 310px;
background-color: #ffffff;
z-index: 1;
}
#media (min-width: 768px) {
.image-holder {
height: 325px;
}
}
.image-holder:before {
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: #4CAF50;
opacity: 0;
z-index: 5;
transition: opacity 0.6s;
}
.image-holder:after {
content: '+';
font-family: 'Raleway', sans-serif;
font-size: 70px;
color: #4CAF50;
text-align: center;
position: absolute;
top: 92.5px;
left: 50%;
width: 75px;
height: 75px;
line-height: 75px;
background-color: #ffffff;
opacity: 0;
border-radius: 50%;
z-index: 10;
transform: translate(-50%, 100%);
box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
transition: all 0.4s ease-out;
}
#media (min-width: 768px) {
.image-holder:after {
top: 107.5px;
}
}
.image-holder .image-holder__link {
display: block;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 15;
}
.image-holder .image-holder--original {
transition: transform 0.8s cubic-bezier(0.165, 0.84, 0.44, 1);
}
.image-liquid {
width: 100%;
height: 325px;
background-size: cover;
background-position: center center;
}
.product-description {
position: absolute;
left: 0;
bottom: 0;
width: 100%;
height: 80px;
padding: 10px 15px;
overflow: hidden;
background-color: #fafafa;
border-top: 1px solid #e5e5e5;
transition: height 0.6s cubic-bezier(0.165, 0.84, 0.44, 1);
z-index: 2;
}
#media (min-width: 768px) {
.product-description {
height: 65px;
}
}
.product-description p {
margin: 0 0 5px;
}
.product-description .product-description__title {
font-family: 'Raleway', sans-serif;
position: relative;
white-space: nowrap;
overflow: hidden;
margin: 0;
font-size: 18px;
line-height: 1.25;
}
.product-description .product-description__title:after {
content: '';
width: 60px;
height: 100%;
position: absolute;
top: 0;
right: 0;
background: linear-gradient(to right, rgba(255, 255, 255, 0), #fafafa);
}
.product-description .product-description__title a {
text-decoration: none;
color: inherit;
}
.product-description .product-description__category {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.product-description .product-description__price {
color: #4CAF50;
text-align: left;
font-weight: bold;
letter-spacing: 0.06em;
}
#media (min-width: 768px) {
.product-description .product-description__price {
text-align: right;
}
}
.product-description .sizes-wrapper {
margin-bottom: 15px;
}
.product-description .color-list {
font-size: 0;
}
.product-description .color-list__item {
width: 25px;
height: 10px;
position: relative;
z-index: 1;
transition: all .2s;
}
.product-description .color-list__item:hover {
width: 40px;
}
.product-description .color-list__item--red {
background-color: #F44336;
}
.product-description .color-list__item--blue {
background-color: #448AFF;
}
.product-description .color-list__item--green {
background-color: #CDDC39;
}
.product-description .color-list__item--orange {
background-color: #FF9800;
}
.product-description .color-list__item--purple {
background-color: #673AB7;
}
</style></head><body>
<!--
Inspired in this dribbble
https://dribbble.com/shots/986548-Product-Catalog
-->
<div class="container">
<div class="row">
<div class="col-xs-12 col-sm-6 col-md-4">
<article class="card-wrapper">
<div class="image-holder">
<div class="image-liquid image-holder--original" style="background-image: url('https://upload.wikimedia.org/wikipedia/commons/2/24/Blue_Tshirt.jpg')">
</div>
</div>
<div class="product-description">
<!-- title -->
<h1 class="product-description__title">
<a href="#">
Adidas Originals
</a>
</h1>
<!-- category and price -->
<div class="row">
<div class="col-xs-12 col-sm-8 product-description__category secondary-text">
Men's running shirt
</div>
<div class="col-xs-12 col-sm-4 product-description__price">
€ 499
</div>
</div>
<!-- divider -->
<hr />
<!-- sizes -->
<div class="sizes-wrapper">
<b>Sizes</b>
<br />
<span class="secondary-text text-uppercase">
<ul class="list-inline">
<li>xs,</li>
<li>s,</li>
<li>sm,</li>
<li>m,</li>
<li>l,</li>
<li>xl,</li>
<li>xxl</li>
</ul>
</span>
</div>
<!-- colors -->
<div class="color-wrapper">
<b>Colors</b>
<br />
<ul class="list-inline color-list">
<li class="color-list__item color-list__item--red"></li>
<li class="color-list__item color-list__item--blue"></li>
<li class="color-list__item color-list__item--green"></li>
<li class="color-list__item color-list__item--orange"></li>
<li class="color-list__item color-list__item--purple"></li>
</ul>
</div>
</div>
</article>
</div>
<div class="col-xs-12 col-sm-6 col-md-4">
<article class="card-wrapper">
<div class="image-holder">
<div class="image-liquid image-holder--original" style="background-image: url('https://upload.wikimedia.org/wikipedia/commons/thumb/7/75/Jeans_BW_2_(3213391837).jpg/543px-Jeans_BW_2_(3213391837).jpg')">
</div>
</div>
<div class="product-description">
<!-- title -->
<h1 class="product-description__title">
<a href="#">
Adidas Originals
</a>
</h1>
<!-- category and price -->
<div class="row">
<div class="col-sm-8 product-description__category secondary-text">
Men's running shirt
</div>
<div class="col-sm-4 product-description__price text-right">
€ 499
</div>
</div>
<!-- divider -->
<hr />
<!-- sizes -->
<div class="sizes-wrapper">
<b>Sizes</b>
<br />
<span class="secondary-text text-uppercase">
<ul class="list-inline">
<li>xs,</li>
<li>s,</li>
<li>sm,</li>
<li>m,</li>
<li>l,</li>
<li>xl,</li>
<li>xxl</li>
</ul>
</span>
</div>
<!-- colors -->
<div class="color-wrapper">
<b>Colors</b>
<br />
<ul class="list-inline color-list">
<li class="color-list__item color-list__item--red"></li>
<li class="color-list__item color-list__item--blue"></li>
<li class="color-list__item color-list__item--green"></li>
<li class="color-list__item color-list__item--orange"></li>
<li class="color-list__item color-list__item--purple"></li>
</ul>
</div>
</div>
</article>
</div>
<div class="col-xs-12 col-sm-6 col-md-4">
<article class="card-wrapper">
<div class="image-holder">
<div class="image-liquid image-holder--original" style="background-image: url('https://upload.wikimedia.org/wikipedia/commons/b/b8/Columbia_Sportswear_Jacket.jpg')">
</div>
</div>
<div class="product-description">
<!-- title -->
<h1 class="product-description__title">
<a href="#">
Adidas Originals
</a>
</h1>
<!-- category and price -->
<div class="row">
<div class="col-sm-8 product-description__category secondary-text">
Men's running shirt
</div>
<div class="col-sm-4 product-description__price text-right">
€ 499
</div>
</div>
<!-- divider -->
<hr />
<!-- sizes -->
<div class="sizes-wrapper">
<b>Sizes</b>
<br />
<span class="secondary-text text-uppercase">
<ul class="list-inline">
<li>xs,</li>
<li>s,</li>
<li>sm,</li>
<li>m,</li>
<li>l,</li>
<li>xl,</li>
<li>xxl</li>
</ul>
</span>
</div>
<!-- colors -->
<div class="color-wrapper">
<b>Colors</b>
<br />
<ul class="list-inline color-list">
<li class="color-list__item color-list__item--red"></li>
<li class="color-list__item color-list__item--blue"></li>
<li class="color-list__item color-list__item--green"></li>
<li class="color-list__item color-list__item--orange"></li>
<li class="color-list__item color-list__item--purple"></li>
</ul>
</div>
</div>
</article>
</div>
<div class="col-xs-12 col-sm-6 col-md-4">
<article class="card-wrapper">
<div class="image-holder">
<div class="image-liquid image-holder--original" style="background-image: url('http://www.publicdomainpictures.net/pictures/20000/nahled/red-shoes-isolated.jpg')">
</div>
</div>
<div class="product-description">
<!-- title -->
<h1 class="product-description__title">
<a href="#">
Adidas Originals
</a>
</h1>
<!-- category and price -->
<div class="row">
<div class="col-sm-8 product-description__category secondary-text">
Men's running shirt
</div>
<div class="col-sm-4 product-description__price text-right">
€ 499
</div>
</div>
<!-- divider -->
<hr />
<!-- sizes -->
<div class="sizes-wrapper">
<b>Sizes</b>
<br />
<span class="secondary-text text-uppercase">
<ul class="list-inline">
<li>xs,</li>
<li>s,</li>
<li>sm,</li>
<li>m,</li>
<li>l,</li>
<li>xl,</li>
<li>xxl</li>
</ul>
</span>
</div>
<!-- colors -->
<div class="color-wrapper">
<b>Colors</b>
<br />
<ul class="list-inline color-list">
<li class="color-list__item color-list__item--red"></li>
<li class="color-list__item color-list__item--blue"></li>
<li class="color-list__item color-list__item--green"></li>
<li class="color-list__item color-list__item--orange"></li>
<li class="color-list__item color-list__item--purple"></li>
</ul>
</div>
</div>
</article>
</div>
</div>
</div>
</body></html>
The sample is made
<html>
<head>
<style>
.hide {
display: none;
}
.myDIV:hover + .hide {
display: block;
color: red;
}
</style>
</head>
<body>
<h2>Display an Element on Hover</h2>
<div class="myDIV">Hover over me.</div>
<div class="hide">I am shown when someone hovers over the div above.</div>
</body>
</html>
For accessibility reasons, you should use the correct semantic tags. Use a figure as a container and include the text to the image as figcaption.
Apply position: absolute to the container and then position: absolute to the figcaption.
Simply hide the figcaption with display: block and make it visible again by using :hover on the wrapping figure element.
figure {
position: relative;
}
figcaption {
position: absolute;
inset: 2px;
display: none;
}
figure:hover figcaption {
display: flex;
}
/* for visualization only */
figure {
display: inline-block;
}
figcaption {
padding: 1em;
justify-content: center;
align-items: center;
background-color: rgba(255, 255, 255, 0.7);
}
img {
border: 2px dashed red;
}
<figure>
<img src="https://via.placeholder.com/200.jpg" alt="placeholder image used for demonstration">
<figcaption>placeholder image used for demonstration</figcaption>
</figure>