I want to make a responsive hover for my pictures but it's not working...
When I add the code to hover, my images lose responsiveness.
This is my html code:
<div class="col-xs-4 col-sm-4 col-md-4 col-lg-4">
<div class="thumbnail">
<div class="media">
<img class="media__image" src="img/06_team.png" alt="">
<div class="media__body">
<h2>asfafs</h2>
<p>asfkasf</p>
</div>
</div>
</div>
</div>
And this is my CSS:
.media {
display: inline-block;
position: relative;
vertical-align: top;
}
.media__image { display: block; }
.media__body {
background: rgba(41, 128, 185, 0.7);
bottom: 0;
color: white;
font-size: 1em;
left: 0;
opacity: 0;
overflow: hidden;
padding: 3.75em 3em;
position: absolute;
text-align: center;
top: 0;
right: 0;
-webkit-transition: 0.6s;
transition: 0.6s;
}
.media__body:hover { opacity: 1; }
.media__body:after,
.media__body:before {
border: 1px solid rgba(255, 255, 255, 0.7);
bottom: 1em;
content: '';
left: 1em;
opacity: 0;
position: absolute;
right: 1em;
top: 1em;
-webkit-transform: scale(1.5);
-ms-transform: scale(1.5);
transform: scale(1.5);
-webkit-transition: 0.6s 0.2s;
transition: 0.6s 0.2s;
}
.media__body:before {
border-bottom: none;
border-top: none;
left: 2em;
right: 2em;
}
.media__body:after {
border-left: none;
border-right: none;
bottom: 2em;
top: 2em;
}
.media__body:hover:after,
.media__body:hover:before {
-webkit-transform: scale(1);
-ms-transform: scale(1);
transform: scale(1);
opacity: 1;
}
.media__body h2 { margin-top: 0; }
.media__body p { margin-bottom: 1.5em; }
Please help me
Related
For my website I want to use a hover function that shows text once hovering over an imgae with the mouse.
Because I want to implement multiple pictures I used a table whichin each td represents one image.
My problem is that once hovering, the overlay shows but there is no text displayed
I'm a complete beginner in html and css, so if there is anything else I can do different and more efficiently, feel free to let me know.
.container {
position: relative;
width: 50%;
}
.moon {
display: block;
width: 100%;
height: auto;
}
.overlay {
position: relative;
top: 0;
bottom: 0;
left: 0;
right: 0;
height: 300px;
width: 300px;
opacity: 0;
transition: .5s ease;
background-color: white;
}
.container:hover {
opacity: 0.6;
filter: alpha(opacity=10);
}
.text {
color: blue;
font-size: 20px;
position: absolute;
top: 50%;
left: 50%;
-webkit-transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
text-align: center;
}
.mr {
position: relative;
float: left;
width: 300px;
padding-left: 40px;
}
.mr:hover {
opacity: 0.6;
filter: alpha(opacity=10);
}
.plant {
position: relative;
width: 300px;
padding-left: 40px;
padding-right: 120px;
float: left;
}
.plant:hover {
opacity: 0.6;
filter: alpha(opacity=10);
}
.karteone {
position: relative;
width: 300px;
padding-top: 40px;
}
.karteone:hover {
opacity: 0.6;
filter: alpha(opacity=10);
}
.kartetwo {
position: relative;
float: left;
width: 300px;
padding-top: 39.5px;
padding-left: 40px;
}
.kartetwo:hover {
opacity: 0.6;
filter: alpha(opacity=10);
}
<body>
<div class="Arbeitsprobe">
<h2 class="myworksample">My Work Samples.</h2>
<h5>Graphic Illustrator</h5>
<center>
<table>
<tr>
<td>
<div class="container">
<img class="moon" src="images/moon.png" alt="moon">
<div class="overlay">
<div class="text">Hello World</div>
</div>
</div>
</td>
<td><img class="mr" src="images/mr.me.png" alt="mr"></td>
<td><img class="plant" src="images/plant planet.png" alt="plant"></td>
</tr>
</table>
</center>
</div>
</body>
You could use tooltip class from css. This will display the tooltip text while hovering.
.tooltip {
position: relative;
display: inline-block;
border-bottom: 1px dotted black;
}
.tooltip .tooltiptext {
visibility: hidden;
width: 120px;
background-color: black;
color: #fff;
text-align: center;
border-radius: 6px;
padding: 5px 0;
/* Position the tooltip */
position: absolute;
z-index: 1;
}
.tooltip:hover .tooltiptext {
visibility: visible;
<div class="tooltip">Hover over me
<span class="tooltiptext">Tooltip text</span>
</div>
If you want the .overlay to appear on .container:hover, then the code sould be: .container:hover .overlay, like so:
.container {
position: relative;
width: 50%;
}
.moon {
display: block;
width: 100%;
height: auto;
}
.overlay {
position: relative;
top: 0;
bottom: 0;
left: 0;
right: 0;
height: 300px;
width: 300px;
opacity: 0;
transition: .5s ease;
background-color: white;
}
.container:hover .overlay{
opacity: 0.6;
filter: alpha(opacity=10);
}
.text {
color: blue;
font-size: 20px;
position: absolute;
top: 50%;
left: 50%;
-webkit-transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
text-align: center;
}
.mr {
position: relative;
float: left;
width: 300px;
padding-left: 40px;
}
.mr:hover {
opacity: 0.6;
filter: alpha(opacity=10);
}
.plant {
position: relative;
width: 300px;
padding-left: 40px;
padding-right: 120px;
float: left;
}
.plant:hover {
opacity: 0.6;
filter: alpha(opacity=10);
}
.karteone {
position: relative;
width: 300px;
padding-top: 40px;
}
.karteone:hover {
opacity: 0.6;
filter: alpha(opacity=10);
}
.kartetwo {
position: relative;
float: left;
width: 300px;
padding-top: 39.5px;
padding-left: 40px;
}
.kartetwo:hover {
opacity: 0.6;
filter: alpha(opacity=10);
}
<body>
<div class="Arbeitsprobe">
<h2 class="myworksample">My Work Samples.</h2>
<h5>Graphic Illustrator</h5>
<center>
<table>
<tr>
<td>
<div class="container">
<img class="moon" src="images/moon.png" alt="moon">
<div class="overlay">
<div class="text">Hello World</div>
</div>
</div>
</td>
<td><img class="mr" src="images/mr.me.png" alt="mr"></td>
<td><img class="plant" src="images/plant planet.png" alt="plant"></td>
</tr>
</table>
</center>
</div>
</body>
Or apply before and/or after in the CSS, like this:
.container {
position: relative;
width: 50%;
}
.moon {
display: block;
width: 100%;
height: auto;
}
.overlay {
position: relative;
top: 0;
bottom: 0;
left: 0;
right: 0;
height: 300px;
width: 300px;
opacity: 0;
transition: .5s ease;
background-color: white;
}
.container:hover {
opacity: 0.6;
filter: alpha(opacity=10);
}
.text {
color: blue;
font-size: 20px;
position: absolute;
top: 50%;
left: 50%;
-webkit-transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
text-align: center;
}
.mr {
position: relative;
float: left;
width: 300px;
padding-left: 40px;
}
.mr:hover {
opacity: 0.6;
filter: alpha(opacity=10);
}
.plant {
position: relative;
width: 300px;
padding-left: 40px;
padding-right: 120px;
float: left;
}
.plant:hover {
opacity: 0.6;
filter: alpha(opacity=10);
}
.karteone {
position: relative;
width: 300px;
padding-top: 40px;
}
.karteone:hover {
opacity: 0.6;
filter: alpha(opacity=10);
}
.kartetwo {
position: relative;
float: left;
width: 300px;
padding-top: 39.5px;
padding-left: 40px;
}
.kartetwo:hover {
opacity: 0.6;
filter: alpha(opacity=10);
}
/* new code from here */
.moon::after {
content: "Hello World";
color: #ffffff;
border: 1px solid #ffffff;
padding: 10px 40px;
display: inline-block;
top: 0;
position: absolute;
margin-top: 55px;
text-align: center;
line-height: 30px;
left: 50px;
text-transform: uppercase;
opacity: 0;
-webkit-transition: opacity 0.35s ease-in-out;
-moz-transition: opacity 0.35s ease-in-out;
-ms-transition: opacity 0.35s ease-in-out;
-o-transition: opacity 0.35s ease-in-out;
transition: opacity 0.35s ease-in-out;
}
.moon:hover::before {
opacity: 1;
transition: opacity 0.35s ease-in-out;
content: "";
background: rgba(0, 0, 0, 0.8);
display: inline-block;
width: 271px;
height: 167px;
top: 0;
position: absolute;
left: 0px;
}
.moon:hover::after {
content: "Hello World";
color: #ffffff;
border: 1px solid #ffffff;
padding: 10px 40px;
display: inline-block;
top: 0;
position: absolute;
margin-top: 55px;
text-align: center;
line-height: 30px;
left: 50px;
text-transform: uppercase;
opacity: 1;
transition: opacity 0.35s ease-in-out;
}
<body>
<div class="Arbeitsprobe">
<h2 class="myworksample">My Work Samples.</h2>
<h5>Graphic Illustrator</h5>
<center>
<table>
<tr>
<td>
<div class="container">
<img class="moon" src="images/moon.png" alt="moon">
<div class="overlay">
<div class="text">Hello World</div>
</div>
</div>
</td>
<td><img class="mr" src="images/mr.me.png" alt="mr"></td>
<td><img class="plant" src="images/plant planet.png" alt="plant"></td>
</tr>
</table>
</center>
</div>
</body>
I'm trying to get the border on my button to appear, it works perfectly with solid background colors but not with a image . You can see the border when clicking on the button but not when mouse over it.
I just want the border to be visible.
<html lang="en"> <head>
<style>
#import url(https://fonts.googleapis.com/css?family=Montserrat);
*, *::after, *::before {
box-sizing: border-box;
}
body {
{ background-image: url("https://cdn.pixabay.com/photo/2016/09/05/15/07/concrete-1646788_960_720.jpg") }
}
.container {
display: flex;
flex-direction: column;
justify-content: center;
height: 100vh;
width: 100vw;
text-align: center;
}
button {
font-family: "Montserrat", sans-serif;
text-transform: uppercase;
}
button {
position: relative;
border: none;
font-size: 18px;
transition: color 0.5s, transform 0.2s, background-color 0.2s;
outline: none;
border-radius: 3px;
margin: 0 10px;
padding: 23px 33px;
border: 3px solid transparent;
}
button:active {
transform: translateY(3px);
}
button::after, button::before {
border-radius: 3px;
}
.shrink-border {
background-color: transparent;
color: #1b1b20;
}
.shrink-border:hover {
background-color: transparent;
box-shadow: none;
color: #E3BD1C;
}
.shrink-border::before {
content: "";
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
border: 3px solid #1b1b20;
transition: opacity 0.3s, border 0.3s;
}
.shrink-border:hover::before {
opacity: 0;
}
.shrink-border::after {
content: "";
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: transparent;
border: 3px solid #E3BD1C;
opacity: 0;
z-index: -1;
transform: scaleX(1.1) scaleY(1.3);
transition: transform 0.3s, opacity 0.3s;
}
.shrink-border:hover::after {
opacity: 1;
transform: scaleX(1) scaleY(1);
}
.material-bubble {
background-color: transparent;
color: #EEC02C;
border: 3px solid #EEC02C;
overflow: hidden;
box-shadow: none;
}
.material-bubble:hover {
color: #EEC02C;
}
.material-bubble::before {
content: "";
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
border: 3px solid #EEC02C;
transition: opacity 0.3s, border 0.3s;
}
.material-bubble:hover::before {
opacity: 0;
}
.material-bubble::after {
content: "";
position: absolute;
top: 0;
left: 0;
width: 200px;
height: 200px;
background-color: #EEC02C;
border-color: #EEC02C;
border-radius: 50%;
transform: translate(-10px, -70px) scale(0.1);
opacity: 0;
z-index: -1;
transition: transform 0.3s, opacity 0.3s, background-color 0.3s;
}
.material-bubble:hover::after {
opacity: 1;
transform-origin: 100px 100px;
transform: scale(1) translate(-10px, -70px);
}
</style>
</head>
<body translate="no">
<div class="container">
<div>
<div style="background-image: url('https://cdn.pixabay.com/photo/2016/09/05/15/07/concrete-1646788_960_720.jpg');">
<a href="https://sites.google.com/u/0/d/1qexyDxBEpBgUx3IVqODoqfLs59AG0eV1/p/1SsjI8NaKooq171w4dA5LW0NvxKX9ACkG/preview?authuser=0">
<button class="shrink-border">Make an Appointment</button>
</a>
</a>
</div>
</div>
</body></html>
Just add a z-index to your border:
.shrink-border {
background-color: transparent;
color: #1b1b20;
z-index: 0; /* <--- Add this */
}
Full working Demo:
<html lang="en"> <head>
<style>
#import url(https://fonts.googleapis.com/css?family=Montserrat);
*, *::after, *::before {
box-sizing: border-box;
}
body {
{ background-image: url("https://cdn.pixabay.com/photo/2016/09/05/15/07/concrete-1646788_960_720.jpg") }
}
.container {
display: flex;
flex-direction: column;
justify-content: center;
height: 100vh;
width: 100vw;
text-align: center;
}
button {
font-family: "Montserrat", sans-serif;
text-transform: uppercase;
}
button {
position: relative;
border: none;
font-size: 18px;
transition: color 0.5s, transform 0.2s, background-color 0.2s;
outline: none;
border-radius: 3px;
margin: 0 10px;
padding: 23px 33px;
border: 3px solid transparent;
}
button:active {
transform: translateY(3px);
}
button::after, button::before {
border-radius: 3px;
}
.shrink-border {
background-color: transparent;
color: #1b1b20;
z-index: 0; /* <--- Add this */
}
.shrink-border:hover {
background-color: transparent;
box-shadow: none;
color: #E3BD1C;
}
.shrink-border::before {
content: "";
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
border: 3px solid #1b1b20;
transition: opacity 0.3s, border 0.3s;
}
.shrink-border:hover::before {
opacity: 0;
}
.shrink-border::after {
content: "";
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: transparent;
border: 3px solid #E3BD1C;
opacity: 0;
z-index: -1;
transform: scaleX(1.1) scaleY(1.3);
transition: transform 0.3s, opacity 0.3s;
}
.shrink-border:hover::after {
opacity: 1;
transform: scaleX(1) scaleY(1);
}
.material-bubble {
background-color: transparent;
color: #EEC02C;
border: 3px solid #EEC02C;
overflow: hidden;
box-shadow: none;
}
.material-bubble:hover {
color: #EEC02C;
z-index: -1;
}
.material-bubble::before {
content: "";
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
border: 3px solid #EEC02C;
transition: opacity 0.3s, border 0.3s;
}
.material-bubble:hover::before {
opacity: 0;
}
.material-bubble::after {
content: "";
position: absolute;
top: 0;
left: 0;
width: 200px;
height: 200px;
background-color: #EEC02C;
border-color: #EEC02C;
border-radius: 50%;
transform: translate(-10px, -70px) scale(0.1);
opacity: 0;
z-index: -1;
transition: transform 0.3s, opacity 0.3s, background-color 0.3s;
}
.material-bubble:hover::after {
opacity: 1;
transform-origin: 100px 100px;
transform: scale(1) translate(-10px, -70px);
}
</style>
</head>
<body translate="no">
<div class="container">
<div>
<div style="background-image: url('https://cdn.pixabay.com/photo/2016/09/05/15/07/concrete-1646788_960_720.jpg');">
<a href="https://sites.google.com/u/0/d/1qexyDxBEpBgUx3IVqODoqfLs59AG0eV1/p/1SsjI8NaKooq171w4dA5LW0NvxKX9ACkG/preview?authuser=0">
<button class="shrink-border">Make an Appointment</button>
</a>
</a>
</div>
</div>
</body></html>
Add this to your css
.shrink-border:hover {
transform: translateY(3px);
}
I am creating a div which will enclose a users name and when they hover over a profile image then it will display the name over the image, when I am doing this it does not center the div over the image solely which will be causing a problem when styling the website.
My CSS is below:
.miniProfileImage {
border-radius: 100%;
border: 3px dashed #28A745;
width: 100%;
max-width: 200px;
height: auto;
transition: .5s ease;
backface-visibility: hidden;
opacity: 1;
display: block;
}
.middle {
transition: .5s ease;
opacity: 0;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
text-align: center;
}
.img-container {
position: relative;
width: 50%;
}
.img-container:hover .miniProfileImage {
opacity: 0.3;
}
.img-container:hover .middle {
opacity: 1;
}
.middleText {
background-color: #4CAF50;
color: white;
font-size: 16px;
padding: 16px 32px;
}
A sample HTML mark-up can be seen here:
<div class='img-container'>
<img class='miniProfileImage' src='http://via.placeholder.com/500x500'>
<div class='middle'>
<p class='middleText'>Some Name</p>
</div>
</div>
I have also created a JS Fiddle to represent what is happening
.miniProfileImage {
border-radius: 100%;
border: 3px dashed #28A745;
width: 100%;
max-width: 200px;
height: auto;
transition: .5s ease;
backface-visibility: hidden;
opacity: 1;
display: block;
}
.middle {
transition: .5s ease;
opacity: 0;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
text-align: center;
}
.img-container {
position: relative;
width: 50%;
}
.img-container:hover .miniProfileImage {
opacity: 0.3;
}
.img-container:hover .middle {
opacity: 1;
}
.middleText {
background-color: #4CAF50;
color: white;
font-size: 16px;
padding: 16px 32px;
}
<div class='img-container'>
<img class='miniProfileImage' src='http://via.placeholder.com/500x500'>
<div class='middle'>
<p class='middleText'>Some Name</p>
</div>
</div>
Thanks
That's because your surrounding <div class='img-container'> has a width that is wider than the image.
If you want the div to have the same size as the image, you can do the following:
.img-container {
position: relative;
display: inline-block;
}
.miniProfileImage {
border-radius: 100%;
border: 3px dashed #28A745;
width: 100%;
max-width: 200px;
height: auto;
transition: .5s ease;
backface-visibility: hidden;
opacity: 1;
display: block;
}
.middle {
transition: .5s ease;
opacity: 0;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
text-align: center;
}
.img-container {
position: relative;
display: inline-block;
}
.img-container:hover .miniProfileImage {
opacity: 0.3;
}
.img-container:hover .middle {
opacity: 1;
}
.middleText {
background-color: #4CAF50;
color: white;
font-size: 16px;
padding: 16px 32px;
}
<div class='img-container'>
<img class='miniProfileImage' src='http://via.placeholder.com/500x500'>
<div class='middle'>
<p class='middleText'>Some Name</p>
</div>
</div>
please correct the CSS like this
.img-container {
position: relative;
width: 100%;
max-width: 210px;
}
and .middle {white-space:nowrap} you can give .miniProfileImage {max-width:100%} to image
I'm trying to set two triangles in the following way:
The two triangles have to go from the middle to the outside of the browser. I tried to set it up with a wrapper and a background-color and then rotate the wrapper, but I cant get it responsive. The code I tried was:
#page-header-wrapper-triangle {
background-color:#e14b41 ;
-webkit-transform: rotate(-12deg) translate3d(0, 0, 0);
-moz-transform: rotate(-12deg);
-o-transform: rotate(-12deg);
-ms-transform: rotate(-12deg);
transform: rotate(-12deg);
margin: 0 -21px;
-webkit-transform-origin: left center;
-moz-transform-origin: left center;
-o-transform-origin: left center;
-ms-transform-origin: left center;
transform-origin: left center;
-webkit-backface-visibility: hidden;
outline: 1px solid transparent;
position: relative;
min-height: 204px;
z-index:1000;
width:80%;
}
#page-header-wrapper-triangle-2 {
background-color:#e14b41 ;
-webkit-transform: rotate(12deg) translate3d(0, 0, 0);
-moz-transform: rotate(12deg);
-o-transform: rotate(12deg);
-ms-transform: rotate(12deg);
transform: rotate(12deg);
margin: 0 -54px;
-webkit-transform-origin: left center;
-moz-transform-origin: left center;
-o-transform-origin: left center;
-ms-transform-origin: left center;
transform-origin: left center;
-webkit-backface-visibility: hidden;
outline: 1px solid transparent;
position: relative;
min-height: 204px;
z-index:1000;
width:80%;
float:right;
top:-520px;
}
<div id="page-header-wrapper-triangle">
<div class="container">
<div class="row">
<div class="right-red col-xs-12 col-sm-6">
</div>
<div class="left-blue col-xs-12 col-sm-6">
</div>
</div>
</div>
</div>
<div id="page-header-wrapper-triangle-2">
<div class="container">
<div class="row">
<div class="right-red col-xs-12 col-sm-6">
</div>
<div class="left-blue col-xs-12 col-sm-6">
</div>
</div>
</div>
</div>
This works when the width of the browser is 1920 px, but s soon as I change the width it doesn't work. I got no clue how I can get this responsive.
I also tried it with background pictures. But this also doesn't work.
You can do it with pseudo selectors :after. It's responsive-ready only for some small and mid widths. But you can easily customize with media queries and change the top and height value.
There is a live example using SCSS
.header {
background-color: grey;
padding-bottom: 60px;
padding-top: 60px;
position: relative;
display: inline-block;
width: 100%;
}
.header .block-left {
float: left;
width: 50%;
}
.header .block-left:after {
background-color: red;
content: ' ';
left: 0;
top: -125px;
height: 200px;
position: absolute;
transform: skew(0deg, -15deg);
width: 50%;
z-index: 20;
}
.header .block-right {
float: right;
width: 50%;
}
.header .block-right:after {
right: 0;
background-color: yellow;
content: ' ';
top: -125px;
height: 200px;
position: absolute;
transform: skew(0deg, 15deg);
width: 50%;
z-index: 20;
}
<div class="header">
<div class="block-left"></div>
<div class="block-right"></div>
</div>
Here's a explanation of how css triangles works : http://codepen.io/chriscoyier/pen/lotjh
#import url(http://fonts.googleapis.com/css?family=Andika);
$stepTiming: 0.8s 0.2s;
.triangle-demo {
width: 100px;
height: 100px;
margin: 0 auto;
background: tan;
border-top: 0 solid #EE7C31;
border-left: 0 solid #F5D97B;
border-bottom: 0 solid #D94948;
border-right: 0 solid #8DB434;
transition: $stepTiming;
.step-1 & {
border-top-width: 10px;
}
.step-2 & {
border-left-width: 10px;
}
.step-3 & {
border-right-width: 10px;
}
.step-4 & {
border-bottom-width: 10px;
}
.step-6 & {
background: transparent;
}
.step-7 & {
width: 0; height: 0;
}
.step-8 & {
border-left-color: transparent;
}
.step-9 & {
border-right-color: transparent;
}
.step-10 & {
border-top-color: transparent;
}
}
.triangle-title {
width: 300px;
padding: 1rem;
color: white;
background: #D94948;
border-radius: 20px;
margin: auto;
opacity: 0;
transition: $stepTiming;
.step-11 & {
opacity: 1;
}
}
body {
background: #333;
font-family: 'Andika', sans-serif;
color: white;
text-align: center;
font-size: large;
transform: translateZ(0);
}
.steps {
position: relative;
height: 45px;
> div {
position: absolute;
top: 0;
left: 0;
width: 100%;
opacity: 0;
background: #333;
transition: 0.3s;
}
.step-0 {
opacity: 1;
}
.step-1 & .step-1 {
opacity: 1;
}
.step-2 & .step-2 {
opacity: 1;
}
.step-5 & .step-5 {
opacity: 1;
}
.step-6 & .step-6 {
opacity: 1;
}
.step-7 & .step-7 {
opacity: 1;
}
.step-8 & .step-8 {
opacity: 1;
}
.step-11 & .step-11 {
opacity: 1;
}
}
h1 {
text-transform: uppercase;
letter-spacing: 1px;
font-size: 1.5rem;
border-bottom: 1px solid #555;
color: #999;
}
FYI http://1stwebdesigner.com/css-shapes/
I would be interested to know if you can make a modal pop-up window just using HTML and CSS without JQuery.
Does anyone know such a simple example?
Thanks in advance!
A modal with only HTML and CSS no jQuery or javascript
body {
color: #333333;
font-family: 'Helvetica', arial;
height: 80em;
}
.wrap {
padding: 40px;
text-align: center;
}
hr {
clear: both;
margin-top: 40px;
margin-bottom: 40px;
border: 0;
border-top: 1px solid #aaaaaa;
}
h1 {
font-size: 30px;
margin-bottom: 40px;
}
p {
margin-bottom: 20px;
}
.btn {
background: #428bca;
border: #357ebd solid 1px;
border-radius: 3px;
color: #fff;
display: inline-block;
font-size: 14px;
padding: 8px 15px;
text-decoration: none;
text-align: center;
min-width: 60px;
position: relative;
transition: color .1s ease;
/* top: 40em;*/
}
.btn:hover {
background: #357ebd;
}
.btn.btn-big {
font-size: 18px;
padding: 15px 20px;
min-width: 100px;
}
.btn-close {
color: #aaaaaa;
font-size: 30px;
text-decoration: none;
position: absolute;
right: 5px;
top: 0;
}
.btn-close:hover {
color: #919191;
}
.modal:before {
content: "";
display: none;
background: rgba(0, 0, 0, 0.6);
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
z-index: 10;
}
.modal:target:before {
display: block;
}
.modal:target .modal-dialog {
-webkit-transform: translate(0, 0);
-ms-transform: translate(0, 0);
transform: translate(0, 0);
top: 20%;
}
.modal-dialog {
background: #fefefe;
border: #333333 solid 1px;
border-radius: 5px;
margin-left: -200px;
position: fixed;
left: 50%;
top: -100%;
z-index: 11;
width: 360px;
-webkit-transform: translate(0, -500%);
-ms-transform: translate(0, -500%);
transform: translate(0, -500%);
-webkit-transition: -webkit-transform 0.3s ease-out;
-moz-transition: -moz-transform 0.3s ease-out;
-o-transition: -o-transform 0.3s ease-out;
transition: transform 0.3s ease-out;
}
.modal-body {
padding: 20px;
}
.modal-header,
.modal-footer {
padding: 10px 20px;
}
.modal-header {
border-bottom: #eeeeee solid 1px;
}
.modal-header h2 {
font-size: 20px;
}
.modal-footer {
border-top: #eeeeee solid 1px;
text-align: right;
}
/*ADDED TO STOP SCROLLING TO TOP*/
#close {
display: none;
}
<div class="wrap">
<h1>Modal - Pure CSS (no Javascript)</h1>
<hr />
Modal!
</div>
<!-- Modal -->
<div class="modal" id="modal-one" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-header">
<h2>Modal in CSS?</h2>
× <!--CHANGED TO "#close"-->
</div>
<div class="modal-body">
<p>One modal example here! :D</p>
</div>
<div class="modal-footer">
Nice! <!--CHANGED TO "#close"-->
</div>
</div>
</div>
</div>
<!-- /Modal -->
Yes, it is possible.
You can use the :target pseudo selector to show a modal.
Here's an example including some transitions as well (code combined from shehary's codepen example and http://tympanus.net/Development/ModalWindowEffects):
body {
background-color: #e74c3c;
}
a {
background-color: #c0392b;
color: #fff;
text-align: center;
width: 200px;
height: 50px;
line-height: 50px;
text-decoration: none;
border-radius: 2px;
}
a:hover {
background-color: #a5281b;
}
body > a {
display: block;
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
}
.md-modal {
position: fixed;
top: 50%;
left: 50%;
width: 50%;
max-width: 630px;
min-width: 320px;
height: auto;
z-index: 2000;
visibility: hidden;
transform: translateX(-50%) translateY(-50%);
}
.md-modal:target {
visibility: visible;
}
.md-overlay {
position: fixed;
width: 100%;
height: 100%;
visibility: hidden;
top: 0;
left: 0;
z-index: 1000;
opacity: 0;
background: rgba(143,27,15,0.8);
transition: all 0.3s;
}
.md-modal:target ~ .md-overlay {
opacity: 1;
visibility: visible;
}
/* Content styles */
.md-content {
color: #fff;
background: #e74c3c;
position: relative;
border-radius: 3px;
margin: 0 auto;
}
.md-content h3 {
margin: 0;
padding: 0.4em;
text-align: center;
font-size: 2.4em;
font-weight: 300;
opacity: 0.8;
background: rgba(0,0,0,0.1);
border-radius: 3px 3px 0 0;
}
.md-content > div {
padding: 15px 40px 30px;
margin: 0;
font-weight: 300;
font-size: 1.15em;
}
.md-content > div p {
margin: 0;
padding: 10px 0;
}
.md-content > div ul {
margin: 0;
padding: 0 0 30px 20px;
}
.md-content > div ul li {
padding: 5px 0;
}
.md-content a {
display: block;
margin: 0 auto;
font-size: 0.8em;
}
/* Effect */
.md-modal .md-content {
-webkit-transform: scale(0.7);
-moz-transform: scale(0.7);
-ms-transform: scale(0.7);
transform: scale(0.7);
opacity: 0;
-webkit-transition: all 0.3s;
-moz-transition: all 0.3s;
transition: all 0.3s;
}
.md-modal:target .md-content {
-webkit-transform: scale(1);
-moz-transform: scale(1);
-ms-transform: scale(1);
transform: scale(1);
opacity: 1;
}
MODAL
<div class="md-modal" id="modal">
<div class="md-content">
<h3>Modal Dialog</h3>
<div>
<p>This is a modal window.</p>
<a class="md-close" href="#">Close me!</a>
</div>
</div>
</div>
<div class="md-overlay"></div>
If you don't feel comfortable using visibility: hidden you can use display: none instead. But you better remove the transitions in that case (visibility can be used in a transition, display can't).