I have my a container wich has a background image a title and button.
I want to hover on the container and change the title text-align to left, same as the button and display some information.
My question is if this is possible using only CSS3?
Here are the images of what I want to do:
(The name doesn't matter it's just an example)
Here's my HTML:
<article class="destination__item destination__item--jacksonhole">
<h2 class="destination__item--name">Jackson Hole</h2>
Ver más
</article>
My CSS:
.destination__item {
padding: 16em 0;
text-align: center;
}
.destination__item--canyons {
background: url(../images/destinos/dest1.jpg) no-repeat;
background-size: cover;
}
.destination__item--name {
color: white;
font-size: 36px;
font-weight: 700;
padding-bottom: .5em;
text-transform: uppercase;
}
.destination__item--btn {
background-color: $color__red--primary;
color: white;
font-weight: 400;
font-size: 14px;
padding: 1em 2.5em;
transition: all .5s ease;
text-transform: uppercase;
&:hover {
text-decoration: none;
background-color: $color__red--dark;
color: white;
}
}
To be honest, I have no idea where to start on the hover state, hope you guys can guide me a little bit.
Sure you can, just add the following to your CSS:
.destination__item:hover .destination__item--name,
.destination__item:hover .destination__item--btn {
display:block;
text-align:left;
}
here is a working example
You can change other div on hover of other example:
.destination__item--jacksonhole:hover + destination__item--name{
text-align: left;
}
To change Content check this Fiddle , text on link is changed.
html:
<article class="destination__item destination__item--jacksonhole">
<h2 class="destination__item--name">Jackson Hole</h2>
<span>Ver más<span>
</article>
CSS:
.destination__item {
padding: 16em 0;
text-align: center;
}
.destination__item--canyons {
background: url(../images/destinos/dest1.jpg) no-repeat;
background-size: cover;
}
.destination__item--name {
color:black;
font-size: 36px;
font-weight: 700;
padding-bottom: .5em;
text-transform: uppercase;
}
.destination__item--btn {
background-color: $color__red--primary;
color: black;
font-weight: 400;
font-size: 14px;
padding: 1em 2.5em;
transition: all .5s ease;
text-transform: uppercase;
&:hover {
text-decoration: none;
background-color: $color__red--dark;
color: white;
}
}
.destination__item:hover .destination__item--name,
.destination__item:hover .destination__item--btn {
display:block;
text-align:left;
}
.destination__item:hover .destination__item--btn span{
display:none;
}
.destination__item:hover .destination__item--btn:after{
content:"New Content"
}
Related
This is my HTML and CSS code. If you run this, there will be a image of a macbook and a 'buy' button. When the browser is minimised, the image is alittle off from the center. When it is in full screen, it causes the image to move up and the 'buy' button gets pushed to the bottom. I tried to use position: fixed but it didnt work. How do you make the picture have fixed position in the middle
.new {
font-family: Arial;
color: rgb(202, 137, 15);
font-size: 18px;
margin-bottom: 15px;
}
.macbook {
font-family: Arial;
font-weight: bold;
font-size: 44px;
margin-top: 0px;
margin-bottom: 10px;
}
.supercharged {
font-family: Arial;
font-weight: bold;
font-size: 60px;
margin-top: 0px;
margin-bottom: 25px;
}
.price {
font-family: Arial;
font-size: 18px;
margin-top: 0px;
}
.button {
background-color: #007aff;
color: white;
border-radius: 100px;
font-weight: bold;
border: none;
padding-left: 16px;
padding-right: 16px;
padding-bottom: 10px;
padding-top: 10px;
position: 50px;
}
.button:hover {
opacity: 0.8;
}
.button:active {
opacity: 0.5;
}
.charged {
color: plum;
text-decoration: underline;
}
.picture {
margin-top: 50px;
}
<!DOCTYPE html>
<html align='center'>
<body>
<p class='new'>New</p>
<h2 class='macbook'>MacBook Pro</h3>
<h1 class='supercharged'><span class='charged'>Supercharged</span> for pros.</h1>
<p class='price'>From $1999</p>
<button class='button'>Buy</button>
<img src="https://images.macrumors.com/t/PV_LL2AlRJvaRvbuXCTUOuDpwzU=/800x0/smart/article-new/2013/09/16-inch-macbook-pro.jpg?lossy" alt="Macbook" class='picture'>
</body>
</html>
Just apply display: block to the <a>-element. When you use display: block on an element, it will try to take up as much width as possible. Seeing as it is not inside a parent container, it will take up 100% width of the <body>-element, as that is the elements closest parent. This way, it won't wrap around the image. The link will however stretch and fill the entire parent container as well. To combat this, apply max-width: fit-content, so the link's width is only relative to its content. Then you can apply margin: auto to center the element again.
For a responsive image, apply max-width: 100% and height: auto. This way it will automatically scale down, as the max-width: 100% property won't let it overflow its parent container (the <body>-element)
body {
text-align: center;
}
.new {
font-family: Arial;
color: rgb(202, 137, 15);
font-size: 18px;
margin-bottom: 15px;
}
.macbook {
font-family: Arial;
font-weight: bold;
font-size: 44px;
margin-top: 0px;
margin-bottom: 10px;
}
.supercharged {
font-family: Arial;
font-weight: bold;
font-size: 60px;
margin-top: 0px;
margin-bottom: 25px;
}
.price {
font-family: Arial;
font-size: 18px;
margin-top: 0px;
}
.button {
background-color: #007aff;
color: white;
border-radius: 100px;
font-weight: bold;
border: none;
padding-left: 16px;
padding-right: 16px;
padding-bottom: 10px;
padding-top: 10px;
position: 50px;
}
.button:hover {
opacity: 0.8;
}
.button:active {
opacity: 0.5;
}
.charged {
color: plum;
text-decoration: underline;
}
.picture {
margin-top: 50px;
max-width: 100%;
height: auto;
}
a {
display: block;
max-width: fit-content;
margin: auto;
}
<p class='new'>New</p>
<h2 class='macbook'>MacBook Pro</h3>
<h1 class='supercharged'><span class='charged'>Supercharged</span> for pros.</h1>
<p class='price'>From $1999</p>
<button class='button'>Buy</button>
<img src="https://images.macrumors.com/t/PV_LL2AlRJvaRvbuXCTUOuDpwzU=/800x0/smart/article-new/2013/09/16-inch-macbook-pro.jpg?lossy" alt="Macbook" class='picture'>
By default an image is displayed inline, which is causing your issue. You're on the right track, but instead of position fixed, position: block; would be a better choice.
(You can also centre your image and avoid it overflowing using a max-width and some margin)
.new {
font-family: Arial;
color: rgb(202, 137, 15);
font-size: 18px;
margin-bottom: 15px;
}
.macbook {
font-family: Arial;
font-weight: bold;
font-size: 44px;
margin-top: 0px;
margin-bottom: 10px;
}
.supercharged {
font-family: Arial;
font-weight: bold;
font-size: 60px;
margin-top: 0px;
margin-bottom: 25px;
}
.price {
font-family: Arial;
font-size: 18px;
margin-top: 0px;
}
.button {
background-color: #007aff;
color: white;
border-radius: 100px;
font-weight: bold;
border: none;
padding-left: 16px;
padding-right: 16px;
padding-bottom: 10px;
padding-top: 10px;
position: 50px;
}
.button:hover {
opacity: 0.8;
}
.button:active {
opacity: 0.5;
}
.charged {
color: plum;
text-decoration: underline;
}
.picture {
margin: 50px auto 0 auto;
display: block;
max-width: 100%;
}
<!DOCTYPE html>
<html align='center'>
<body>
<p class='new'>New</p>
<h2 class='macbook'>MacBook Pro</h3>
<h1 class='supercharged'><span class='charged'>Supercharged</span> for pros.</h1>
<p class='price'>From $1999</p>
<button class='button'>Buy</button>
<img src="https://images.macrumors.com/t/PV_LL2AlRJvaRvbuXCTUOuDpwzU=/800x0/smart/article-new/2013/09/16-inch-macbook-pro.jpg?lossy" alt="Macbook" class='picture'>
</body>
</html>
For some reason the background color refuses to change from white. I am trying to get it to change from white to black under the header, but it refuses to change. Putting "background-color:" in the body SCSS doesn't seem to change it.
I am not sure if there is something in my SCSS that is simply over riding the background color without me realizing?
Any help is greatly appreciated
SCSS:
*{
margin: 0;
padding: 0;
text-decoration: none;
list-style: none;
background-color: '#010101';
}
#wrapperHeader {
width: 100vw;
height: 210px; /* height of the background image? */
background:url(images/header.png);
}
div#wrapperHeader div#header {
width: 100vw;
height:100px;
margin:0 auto;
}
div#wrapperHeader div#header img {
width: 100vw ; /* the width of the logo image */
height: 210px ; /* the height of the logo image */
margin:0 auto;
}
header {
color: white;
background-color: dimgrey ;
clear: left;
text-align: center;
}
.toggle_menu{
position: fixed;
padding: 17px 20px 15px 15px;
margin-top: 210px;
color: white;
cursor: pointer;
background-color: #000;
z-index: 1000000;
font-size: 2em;
opacity: 0;
}
.sidebar_menu{
position: fixed;
width: 100vh;
max-width: 250px;
margin-left: 0px;
overflow: hidden;
height: 100vh;
max-height: 100vh;
background-color: rgba(17, 17, 17, 0.9);
opacity: 0,9;
transition: all 0.3s ease-in-out;
}
.fa-times{
right: 10px;
top: 10px;
opacity: 0.7;
cursor: pointer;
position: absolute;
color: red;
transition: all 0.3s ease-in-out;
}
.fa-times:hover{
opacity: 1 ;
}
.boxed_item {
font-family: 'Open Sans';
font-weight: 200;
padding: 10px 20px;
display: inline-block;
border: solid 2px white;
box-sizing: border-box;
font-size: 22px;
color: white;
text-align: center;
margin-top: 70px;
}
.logo_bold{
font-weight: 800;
}
.logo_title{
color: white;
font-family: 'Open Sans';
font-weight: 200;
font-size: 12px;
text-align: center;
padding: 5px 0px;
}
.nav_selection{
margin: 0, 0;
display: block;
width: 200;
margin-top: 100px;
margin-left: 5px;
}
.nav_item{
font-weight: 200;
font-family: 'Open Sans';
color: white;
padding: 15px 0;
font-size: 20px;
color: #D8D8D8;
border-bottom: solid 2px #D8D8D8;
transition: all 0.3s ease-in-out;
}
.hide_menu{
margin-left: -250px;
}
.opacity_one{
opacity: 1;
}
.disabled {
pointer-events:none; //This makes it not clickable
opacity:0.6;
font-weight: 200;
font-family: 'Open Sans';
color: white;
padding: 15px 0;
font-size: 20px;
color: #D8D8D8;
border-bottom: solid 2px #D8D8D8;
transition: all 0.3s ease-in-out;
}
At three place you have give the background color code in three different style.
Please follow anyone format.
Never give the color in the quotation mark. You have given it in *{ background-color: '#010101'; } remember that. It should be *{ background-color: #010101; }.
You have given background-color: dimgrey ; so each time the color name is not working you have gave the color code for that.
This is header part for which you have to make change. for dimgrey the color code is: #696969 so your code will be:
header {
color: white;
background-color: #696969; // check this line.
clear: left;
text-align: center;
}
It will make the change in the header parts background color. you have to check only that part.
It may be possible that other style will be override the background of header. In that case you have to put the !important in the code like this:
header {
color: white;
background-color: #696969 !important; // check this line.
clear: left;
text-align: center;
}
Let me know if it help you.
Change background-color: '#010101'; this to
background-color: '#010101!important';
I asked a question some days ago about resizing a div when resizing the browser so that it looks good on desktop and on mobile devices. But now I have an extended problem to the same. I have 2 divs one below the other and the bottom footer div resizes on resizing the browser. The working solution can be found here in my previous post: Resize div on resizing window
But in the problem here, I added another div on top of it. On resizing the browser window, the divs don't stack on top of one another. They work fine on a full window on a desktop. Would appreciate any suggestions that you may have or if you'd like to modify the sample code - that would be great!
.info-banner {
position: fixed;
width: 100%;
font-family: Arial, sans-serif;
font-size: 24px;
background: #000000;
color: #FFFFFF;
text-align: center;
bottom: 30px;
left: 0%;
opacity: 0.8;
}
.info-banner a {
color: #FFFFFF;
text-decoration: none;
}
.info-banner a:hover {
color: #aaa;
}
.footer-box {
position: fixed;
font-family: Arial, sans-serif;
color: #FFFFFF;
background-color: #000000;
font-size: 11px;
width: 100%;
opacity: 0.8;
z-index: 50;
bottom: 0px;
left: 0px;
}
.footer-box h2 {
margin-top: 0;
margin-bottom: 0;
font-size: 20px;
text-align: center;
line-height: 30px;
font-weight: normal;
font-family: Arial, sans-serif;
color: #A9A9A9;
}
.footer-box a {
text-decoration: none;
outline: none;
color: #A9A9A9;
}
.footer-box a:hover {
text-decoration: underline;
}
<div id="contact-footer-merged">
<div id="contact-banner" class="info-banner">
<div>HEADER</div>
<div>SUB-HEADER</div>
<div>SUB-SUB-HEADER</div>
</div>
<div class="footer-box">
<h2>
LINK |
LINK |
LINK |
LINK |
LINK |
LINK |
LINK
</h2>
</div>
</div>
</div>
You have 'posititon:static' assigned to both '.footer-box' and ''#contact-banner'' elements. The '#contact-banner' element has a bottom position of 30px, so when the '.footer-box' list elements stack it increases the height of that element. Once the height of the '.footer-box' element is greater than 30px, it will overlap the '#contact-banner' element.
To solve this issue I have just remove position:static from both of those elements and added it to the '#contact-footer-merged' wrapper.
#contact-footer-merged {
position:fixed;
bottom:0;
left:0;
right:0;
width:100%;
}
.info-banner {
font-family: Arial, sans-serif;
font-size: 24px;
background: #000000;
color: #FFFFFF;
text-align: center;
opacity: 0.8;
}
.info-banner a {
color: #FFFFFF;
text-decoration: none;
}
.info-banner a:hover {
color: #aaa;
}
.footer-box {
font-family: Arial, sans-serif;
color: #FFFFFF;
background-color: #000000;
font-size: 11px;
opacity: 0.8;
z-index: 50;
}
.footer-box h2 {
margin-top: 0;
margin-bottom: 0;
font-size: 20px;
text-align: center;
line-height: 30px;
font-weight: normal;
font-family: Arial, sans-serif;
color: #A9A9A9;
}
.footer-box a {
text-decoration: none;
outline: none;
color: #A9A9A9;
}
.footer-box a:hover {
text-decoration: underline;
}
<div id="contact-footer-merged">
<div id="contact-banner" class="info-banner">
<div>HEADER</div>
<div>SUB-HEADER</div>
<div>SUB-SUB-HEADER</div>
</div>
<div class="footer-box">
<h2>
LINK |
LINK |
LINK |
LINK |
LINK |
LINK |
LINK
</h2>
</div>
</div>
</div>
I want to show a div named dot-menu when hover the after content of h1. I have tried the following code but did't work.
h1{
font-size: 20px;
font-weight: 400;
color: #3d3d3d;
margin-top:50px
}
h1:after{
content: "\22EE";
float: right;
font-size: 35px;
padding-right: 20px;
}
.dot-menu{
float: right;
background-color: #3d3d3d;
color: #FFFFFF;
font-size: 16px;
padding: 10px;
font-weight: 400;
font-family: "Montserrat Light", "Open Sans";
position: relative;
top:-10px;
opacity:0;
}
h1:after:hover .dot-menu{
opacity:1;
}
<h1>Henry Little</h1><h3 class="dot-menu">about</h3>
Your selector h1:after:hover .dot-menu is wrong.
This selector will look for .dot-menu element that is descendant of h1 but this is not the case. And 2nd you can't select another element on hover of a pseudo element.
You will need to change your code a bit. Consider the following HTML:
<h1>Henry Little
<span class="icon">⋮</span>
<span class="dot-menu">about</span>
</h1>
Make menu opener and menu both child elements of same parent. Then you can show menu on hover of icon with Sibling (+ ) selector.
h1 .icon:hover + .dot-menu{
opacity:1;
}
h1{
font-size: 20px;
font-weight: 400;
color: #3d3d3d;
margin-top:50px;
position: relative;
}
h1:after {
display: block;
clear: both;
content: '';
}
h1 .icon {
float: right;
font-size: 35px;
padding-right: 20px;
position: relative;
cursor: pointer;
}
.dot-menu {
float: right;
background-color: #3d3d3d;
color: #FFFFFF;
font-size: 16px;
padding: 10px;
font-weight: 400;
font-family: "Montserrat Light", "Open Sans";
position: relative;
top:30px;
opacity:0;
right: 0;
}
h1 .icon:hover + .dot-menu{
opacity:1;
}
<h1>Henry Little
<span class="icon">⋮</span>
<div class="dot-menu">about</div>
</h1>
See this just after making the .dot-menu a child of h1 it is working.
h1{
font-size: 20px;
font-weight: 400;
color: #3d3d3d;
margin-top:50px
}
h1:after{
content: "\22EE";
float: right;
font-size: 35px;
padding-right: 20px;
}
.dot-menu{
float: right;
background-color: #3d3d3d;
color: #FFFFFF;
font-size: 16px;
padding: 10px;
font-weight: 400;
font-family: "Montserrat Light", "Open Sans";
position: relative;
top:-10px;
opacity:0;
}
h1:hover .dot-menu{
opacity:1;
}
<h1>Henry Little<span class="dot-menu">about</span></h1>
I am trying to create a full page transition using #Keyframes and CSS3 only without JavaScript.
Now I am stuck with my codes. Wondering if it is possible when I click on the link it will create a full page transition that moves from bottom to upward like this: http://burtonfeelgoodsnowboard.com/test/
Here's my HTML:
<div class="moveTop">
<h1>Page</h1>
<nav>
Page Up
</div>
and here's the CSS:
/*! HTML5 Boilerplate v4.3.0 | MIT License | http://h5bp.com/ */
html,
button,
input,
select,
textarea {
color: #222;
}
html {
font-size: 1em;
line-height: 1.4;
}
::-moz-selection {
background: #b3d4fc;
text-shadow: none;
}
::selection {
background: #b3d4fc;
text-shadow: none;
}
hr {
display: block;
height: 1px;
border: 0;
border-top: 1px solid #ccc;
margin: 1em 0;
padding: 0;
}
audio,
canvas,
img,
video {
vertical-align: middle;
}
fieldset {
border: 0;
margin: 0;
padding: 0;
}
textarea {
resize: vertical;
}
body{
font: 16px/1.5 'Lato', Arial, sans-serif;
background: #3498db;
color: #ffffff;
}
h1{
font-size: 50px;
font-weight: 300;
text-align: center;
}
span{
color: #2980b9;
font-weight: bold;
}
h2{
font-size: 35px;
text-align: left;
margin-left: -20px;
}
nav{
width: 28.09%;
margin: 0 auto;
display: block;
}
nav a {
font-size: 19px;
display: inline-block;
text-align: center;
font-family: 'Lato', sans-serif;
color: #2980b9;
font-weight: 400;
padding: 5px 15px;
text-transform: uppercase;
border-radius: 2px;
letter-spacing: 1px;
text-decoration: none;
margin-right: 10px;
border: 2px solid #ecf0f1;
border-radius: none;
}
nav a.active,nav a:hover {
background: #ecf0f1;
color: #3498db;
}
}
.moveTop{
-webkit-animation: moveToTop .6s ease both;
animation: moveToTop .6s ease both;
}
#keyframes moveFromTop {
from { -webkit-transform: translateY(-100%); transform: translateY(-100%); }
}
My JSFIDDLE: https://jsfiddle.net/6z5LsL6r/
Anyone who can show me the OUTPUT VIA JSFIDDLE?
Thank in advance guys!
You can use :target selector to work around: https://jsfiddle.net/6z5LsL6r/3/