This is what I want it to look like:
everything that is inside the red div, must go behind the green div.
The html:
<div style="height: 100px">some text blablablablablablabla
<br/>some text blablablablablablabla
<br/>some text
<br/>some text
<br/>some text
<br/>some text
<br/>some text
<br/>
</div>
<nav class="navigation">
<div class="navfake"></div>
<div class="singleelement">
<div class="container">
<div class="title">Some Title1</div>
<div class="titlepicture">some picture</div>
</div>
</div>
<div class="singleelement">
<div class="container">
<div class="title">Some Title2</div>
<div class="titlepicture">some picture</div>
</div>
</div>
</nav>
The CSS so far and sadly not working:
nav {
width: 100%;
height: 60px;
position: relative;
}
.navfake {
width: 100%;
height: 100%;
background: green;
z-index: 10;
}
.singleelement {
display: inline-block;
width: 100px;
height: 60px;
text-align: center;
z-index: 0;
}
.container {
position: absolute;
top: 0px;
-webkit-transition: all .8s ease;
-moz-transition: all .8s ease;
-ms-transition: all .8s ease;
-o-transition: all .8s ease;
transition: all .8s ease;
height: 200px;
}
.titlepicture {
width: 100%;
height: 200px;
background-color: red;
}
.singleelement:hover .container {
top: -80px;
}
enter link description here
Credits also for: #Toskan, thank you
DEMO WORKING
Here's the new css
nav {
width: 100%;
height: 60px;
position: relative;
}
.navfake {
width: 100%;
height: 100%;
background: green;
z-index: 10;
position:relative;
}
.singleelement {
display: inline-block;
width: 100px;
height: 60px;
text-align: center;
}
.container {
position: absolute;
top: 0px;
-webkit-transition: all .8s ease;
-moz-transition: all .8s ease;
-ms-transition: all .8s ease;
-o-transition: all .8s ease;
transition: all .8s ease;
height: 200px;
}
.titlepicture {
position:absolute; /*THIS ADDED*/
width: 100%;
height: 200px;
background-color: red;
z-index:1; /*THIS ADDED*/
}
.singleelement:hover .container {
top: -80px;
}
.title{ /*THIS ADDED*/
z-index:555;
position:relative;
}
HTML:
<br><br>
<div style="height: 100px">some text blablablablablablabla
<br/>some text blablablablablablabla
<br/>some text
<br/>some text
<br/>some text
<br/>some text
<br/>some text
<br/>
</div>
<nav class="navigation">
<div class="navfake"></div>
<div class="singleelement">
<div class="container">
<div class="title">Some Title1</div>
<div class="titlepicture">some picture</div>
</div>
</div>
<div class="singleelement">
<div class="container">
<div class="title">Some Title2</div>
<div class="titlepicture">some picture</div>
</div>
</div>
</nav>
http://jsfiddle.net/hL5gW/4/
Adding position absolute and doing some positioning this is incredibly simple.
I added these styles to the second element. You'll just have to add it to a seperate class for the second element, or just add it to singleelement if you want this to apply to both.
<div class="singleelement" style="z-index:-100;position:absolute;margin-top:-60px;">
Related
I have the following html code :
.logo {
display: inline-block;
width: 30px;
position: absolute;
top: 50%;
opacity: 0;
transition: 0.6s;
}
.container:hover .logo {
opacity: 1;
transition: 0.6s;
}
.container:hover .picture {
filter: brightness(0.7);
transition: 0.6s;
}
<div class="container">
<div class="element-header">
<div class="element">Foo</div>
<div class="element">Bar</div>
</div>
<div class="loader"> </div>
<img src="logo.png" alt="" class="logo">
<img src="picture.jpg" alt="" class="picture">
</div>
When .container is hovered, I want .logo to be at opacity:1 and .picture to be at filter: brightness(0.7).
When a try to apply those properties one-by-one at .container hover, each is working. But when both are set-up, only the filter one is working.
If you set the position to relative instead of absolute, both images will display. As the code stood, one image was getting lost. (I substituted my own images in and added a picture class to size the image)
The transition works fine though!
Try below:
.logo {
display: inline-block;
width: 100px;
//height:auto;
position: relative;
top: 50%;
opacity: 0;
transition: 0.6s;
}
.picture {
width: 500px;
height: auto;
float: left;
}
.container:hover .logo {
opacity: 1;
transition: 0.6s;
}
.container:hover .picture {
filter: brightness(0.7);
transition: 0.6s;
}
<div class="container">
<div class="element-header">
<div class="element">Foo</div>
<div class="element">Bar</div>
</div>
<div class="loader"> </div>
<img src="https://www.dcu.ie/sites/default/files/afu_logo2_1.jpg" alt="agefriendly" class="logo">
<img src="http://www.rachelgallen.com/images/mountains.jpg" alt="Mountains" class="picture">
</div>
Fiddle here
I have kind of a thumbnail with an image and some text inside. When I hover over the image, it zooms in.
Here is a fiddle:
https://jsfiddle.net/ShiroiOkami/r1awd3b4/
I want to achieve an effect that the image just zooms in, but it's size stays the same. I don't want it to grow. How to do it?
P.S. the code for instance:
<div class="wrapper">
<img src="https://pixabay.com/static/uploads/photo/2015/10/01/21/39/background-image-967820_960_720.jpg" style="width:150px;" class="grow">
<div class="description">
<h3>
Some title
</h3>
<p>
some text
</p>
</div>
CSS:
.wrapper{
background-color: #fff;
text-align: center;
width: 150px;
overflow: hidden;
}
.grow{
transition: all .2s ease-in-out;
-webkit-transition: all .2s ease-in-out;
-moz-transition: all .2s ease-in-out;
-ms-transition: all .2s ease-in-out;
-o-transition: all .2s ease-in-out;
}
.grow:hover{
transform: scale(1.1);
-webkit-transform: scale(1.1);
-moz-transform: scale(1.1);
-ms-transform: scale(1.1);
-o-transform: scale(1.1);
}
.description{
background-color: #fff;
overflow: hidden;
}
I've fixed your fiddle, so you'll get the required effect: https://jsfiddle.net/r1awd3b4/1/
What I've done is add an extra wrapper div around the image:
<div class="img-wrapper">
<img src="..." class="grow">
</div>
CSS:
.img-wrapper{
width: 100%;
height: 150px;
overflow: hidden;
}
.img-wrapper img{
display: block;
width: 100%;
}
Now the image can grow all it wants but since the wrapper will not, the image will not 'grow', but just 'zoom'.
may be you mean this effect?:
<div class="wrapper">
<div class="img-container">
<img src="https://pixabay.com/static/uploads/photo/2015/10/01/21/39/background-image-967820_960_720.jpg" style="width:150px;" class="grow">
</div>
<div class="description">
<h3>Some title</h3>
<p>some text</p>
</div>
</div>
and the css:
.img-container {
width: 150px;
height: 150px;
overflow: hidden;
}
Would I like to know how I can put in a div 100% height?
I have a div with an image and a div with content.
The image has a width 100%, and the same content but does not fill the entire image div.
I copied the code if you can help.
Thank you,
#carta div{
position: relative;
display: table;
}
#carta div .overlay{
width: 100%;
height: 100%;
background: rgba(0,0,0,.7);
position: absolute;
top:0;
text-align: center;
color:white;
cursor: pointer;
opacity: 0;
-webkit-transition:all .4s ease-out;
transition:all .4s ease-out;
}
#carta .overlay:hover{
opacity: 1;
width: 100%;
height: 100%;
}
#carta .col-1-4{
padding: 0;
margin:0;
}
#carta div img{
width: 100%;
display: table;
}
#carta .overlay p{
font-style: oblique;
font-size: 20px;
padding-top: 50px;
text-align: center;
border-top: 1px solid white;
-webkit-transition:all .4s ease-out;
transition:all .4s ease-out;
}
#carta .overlay h5{
font-size: 30px;
margin: 50px;
}
<div class="clearFix">
<div class="col-1-4">
<img src="img/carta/atun.jpg" alt="atún revuelto"/>
<div class="overlay">
<h5>Atun revuelto</h5>
<p>15€</p>
</div>
</div>
<div class="col-1-4">
<img src="img/carta/especialidaditaliana.jpg" alt="especialidad italiana"/>
<div class="overlay">
<h5>Especialidad Italiana</h5>
<p>15€</p>
</div>
</div>
</div>
Thank you very much for your responses.
I have solved by adding "display: table-cell" in the css class ".overlay"
Thus occupies the div, which occupies the image.
Many thanks
Use background in css,something like this: background: url(img/carta/especialidaditaliana.jpg);
You also can use div to set background
Like this: <div class="img">content</div> but you also need css background.
Something like this?It should work in .html document...
<style>
.img {
position: relative;
width: 200px;
height: 100%;
background: url(http://goo.gl/ytbJn8);
color: white;
}
</style>
<div class="img">This is text. This is text. This is text. This is text. This is text. This is text. This is text. This is text. This is text.</div>
<div class="box"></div>
I have a line of 8 divs within divs on this page.
http://etreecycle.co.uk/websites/MPW/admin/
As you can see when you hover the expanding effect causes the line of divs to move place. This has only started happening since I added the images to the centre.
EDIT; I added the link at the same time as the images. This may be causing the change.
Note; the divs are made with a PHP loop, so I can't style one differently then another.
This is the basic code;
<div class="option-box">
<a href="<?php echo './?page='.$box['page'][0]; ?>">
<div class="inner">
<div class="content">
<img alt="<?php echo $box['name'][0]; ?>" src="<?php echo $box['image_URL'][0]; ?>"/>
</div>
</div>
</a>
</div>
And this is the CSS;
/*********** Option Boxes ***********/
.option-box-wrap {
position: relative;
width: 1210px;
margin: 0 auto;
}
.option-box {
width: 300px;
margin: 0 auto;
position: relative;
display: inline-block;
}
.option-box .inner {
position: relative;
padding-bottom: 30px;
height: 300px;
text-align: center;
}
.option-box .inner .content:after {
content:'';
display: block;
position: absolute;
left: 12%;
bottom: 0px;
width: 80%;
max-width: 210px;
height: 10px;
background: transparent;
border-radius: 100px/50px;
box-shadow: 0 50px 40px rgba(0,0,0,0.8);
}
.option-box .inner .content {
border: 4px solid #fff;
border-radius: 20px;
background: -webkit-linear-gradient(#8AC007 100%, #8ac007 0%, #a5e116 100%);
width: 240px;
height: 240px;
display: block;
position: relative;
margin: 0 auto;
-webkit-transition: all .2s ease;
-moz-transition: all .2s ease;
-ms-transition: all .2s ease;
-o-transition: all .2s ease;
transition: all .2s ease;
}
.option-box .inner .content:hover {
width: 250px;
height: 250px;
}
.option-box .inner .content img {
width: 90%;
height: 90%;
margin: 5%;
}
This is a case where float: left wins over display: inline-block. You're using inline-block in order to make your div's sit next to each other. When you hover the height changes and pushes the other elements down. If you use float: left then the elements are taken out of the flow of the document and can no longer influence each other in such a way.
/*********** Option Boxes ***********/
.option-box-wrap {
position: relative;
width: 1210px;
margin: 0 auto;
}
.option-box {
width: 300px;
margin: 0 auto;
position: relative;
float: left;
}
.option-box .inner {
position: relative;
padding-bottom: 30px;
height: 300px;
text-align: center;
}
.option-box .inner .content:after {
content:'';
display: block;
position: absolute;
left: 12%;
bottom: 0px;
width: 80%;
max-width: 210px;
height: 10px;
background: transparent;
border-radius: 100px/50px;
box-shadow: 0 50px 40px rgba(0,0,0,0.8);
}
.option-box .inner .content {
border: 4px solid #fff;
border-radius: 20px;
background: -webkit-linear-gradient(#8AC007 100%, #8ac007 0%, #a5e116 100%);
width: 240px;
height: 240px;
display: block;
position: relative;
margin: 0 auto;
-webkit-transition: all .2s ease;
-moz-transition: all .2s ease;
-ms-transition: all .2s ease;
-o-transition: all .2s ease;
transition: all .2s ease;
}
.option-box .inner .content:hover {
width: 250px;
height: 250px;
}
.option-box .inner .content img {
width: 90%;
height: 90%;
margin: 5%;
}
<div class="option-box">
<a href="#">
<div class="inner">
<div class="content">
<img alt="" src="http://lorempixel.com/300/300/city"/>
</div>
</div>
</a>
</div><div class="option-box">
<a href="#">
<div class="inner">
<div class="content">
<img alt="" src="http://lorempixel.com/300/300/food"/>
</div>
</div>
</a>
</div><div class="option-box">
<a href="#">
<div class="inner">
<div class="content">
<img alt="" src="http://lorempixel.com/300/300/nightlife"/>
</div>
</div>
</a>
</div><div class="option-box">
<a href="#">
<div class="inner">
<div class="content">
<img alt="" src="http://lorempixel.com/300/300/sports"/>
</div>
</div>
</a>
</div><div class="option-box">
<a href="#">
<div class="inner">
<div class="content">
<img alt="" src="http://lorempixel.com/300/300/people"/>
</div>
</div>
</a>
</div><div class="option-box">
<a href="#">
<div class="inner">
<div class="content">
<img alt="" src="http://lorempixel.com/300/300/transport"/>
</div>
</div>
</a>
</div><div class="option-box">
<a href="#">
<div class="inner">
<div class="content">
<img alt="" src="http://lorempixel.com/300/300/cats"/>
</div>
</div>
</a>
</div><div class="option-box">
<a href="#">
<div class="inner">
<div class="content">
<img alt="" src="http://lorempixel.com/300/300/abstract"/>
</div>
</div>
</a>
</div>
Simply changing display: block to float: left fixes the issue. This is not the only way to fix it, just one of many. If you use this way you will want to make sure to clear your float. The clearfix method works nicely.
When you animate the height property, the size of the animated container changes, and so the entire "row" of images takes more space, which pushes the next row downwards. Have a look at this illustration (the background was colored red for clarity):
Instead of animating via width and height properties, which affect a layout change in the page, simply use the transform property, which doesn't affect the page flow:
.option-box .inner .content:hover {
-webkit-transform: scale(1.1); /* Chrome, Opera 15+, Safari 3.1+ */
-ms-transform: scale(1.1); /* IE 9 */
transform: scale(1.1); /* Firefox 16+, IE 10+, Opera */
}
The resulting change should look like this:
I have a little problem that i can't resolve, cause i want use solo CSS. I just want to do the opposite of what my code does, but i couldn't found the way to do it. That's my code:
HTML:
<div class="central1">
<div id="central_imgl">
<img class="bottom" src="images/kostnic_central1.jpg" width="370px" height="400px"/>
<img class="top1 hover" src="images/kostnic.jpg" width="370px" height="400px"/>
</div>
<div id="central_imgr">
<img class="bottom" src="images/kostnic_central2.jpg" width="370px" height="400px"/>
<img class="top1 hover" src="images/kdata2.jpg"/>
</div>
</div>
CSS:
div.central1{
background: black;
display: block;
position: absolute;
width: 740px;
height: 400px;
top:190px;
left:350px;
color: white;
}
#central_imgl {
position:relative;
float: left;
width: 50%;
height: 100%;
margin:0 auto;
}
#central_imgl img {
position:absolute;
left:0;
width: 368px;
height: 400px;
-webkit-transition: opacity 1s ease-in-out;
-moz-transition: opacity 1s ease-in-out;
-o-transition: opacity 1s ease-in-out;
transition: opacity 1s ease-in-out;
}
#central_imgl img.top1:hover {
opacity:0;
}
(And the same for central_imgr with float:right)
Now I want to change the displayed img on 'central_imgr' when i hover central_imgl, keeping the frontal img of central_imgl, and vice versa.
Thanks all!
DEMO
css code:
*{
box-sizing:border-box;
}
div.central1{
background: black;
display: block;
position: absolute;
width: 740px;
height: 400px;
top:190px;
left:350px;
color: white;
border:4px solid black;
overflow:hidden;
}
[id^=central] {
position:relative;
float: left;
width: 50%;
height: 100%;
}
[id=hiddenDiv]{
position:absolute;
right: 0;
width: 50%;
height: 100%;
z-index:1;
}
img {
position:absolute;
left:0;
top:0;
width: 100%;
height: 400px;
transition: opacity 1s ease-in-out;
}
#central_imgl .top1:hover {
opacity:0;
}
#central_imgl:hover + [id=central_imgr] .hover{
opacity:0;
}
[id=hiddenDiv]:hover + #central_imgl .top1{
opacity:0;
}
html code:
<div class=central1>
<div id=hiddenDiv></div>
<div id="central_imgl">
<img class=bottom src="https://scontent-b-fra.xx.fbcdn.net/hphotos-frc3/l/t1.0-9/1604926_659171170797962_1284145215_n.jpg" width="370px" height="400px"/>
<img class="top1 hover" src="https://scontent-a-fra.xx.fbcdn.net/hphotos-frc1/t1.0-9/10154320_659171017464644_1223781208_n.jpg" width="370px" height="400px"/>
</div>
<div id=central_imgr>
<img class=bottom src="https://scontent-b-fra.xx.fbcdn.net/hphotos-prn2/t1.0-9/1234076_659170960797983_1698005470_n.jpg" width="370px" height="400px"/>
<img class="top1 hover" src="https://fbcdn-sphotos-g-a.akamaihd.net/hphotos-ak-ash3/t1.0-9/10156133_658968587484887_710971290_n.jpg"/>
</div>
</div>