I have a question regarding my previous post:
Animation stop with css3
The slider works perfect in Chrome. In firefox however it is not working properly. Does anyone here have an idea?
Slider can be found here http://jimmytenbrink.nl/slider/
It looks like there is a problem in firefox with positioning absolute + display: table-cell.
My code is as follows:
<header>
<div>
<img src="./images/ironman.png">
<span>Ironman</span>
</div>
<div>
<img src="./images/ironman.png">
<span>Ironman</span>
</div>
<div>
<img src="./images/ironman.png">
<span>Ironman</span>
</div>
<div>
<img src="./images/ironman.png">
<span>Ironman</span>
</div>
<div >
<img src="./images/ironman.png">
<span>Ironman</span>
</div>
<div>
<img src="./images/ironman.png">
<span>Ironman</span>
</div>
<div>
<img src="./images/ironman.png">
<span>Ironman</span>
</div>
<div>
<img src="./images/ironman.png">
<span>Ironman</span>
</div>
</header>
And the css;
header {
margin-top: 10px;
width: 1185px;
display: table;
overflow: hidden;
background-color: #000;
height: 500px;
}
header > div {
background: url('./images/iron_man_bg.jpg');
width: 123.8px;
height: 500px;
position: relative;
-webkit-transition: width .3s;
transition: width .3s;
display: table-cell;
border: 2px solid #fff;
overflow: hidden;
}
header div:first-child {
margin-left: 0px;
}
header div:last-child{
margin-right: 0px;
}
header div:hover span {
left: 50px;
opacity: 1;
}
header > div img {
position: absolute;
left: -240px;
-webkit-transition: all .3s;
transition: all .3s;
-webkit-filter: grayscale(1);
overflow:hidden;
}
header > div span {
-webkit-transition: left .3s;
transition: left .3s;
position: absolute;
bottom: 30px;
color: white;
left: -70px;
opacity: 0;
width: 151px;
font-family: 'Fugaz One', cursive;
text-transform: uppercase;
color: #fff;
font-size: 24px;
text-shadow: 0px 0px 10px #f1f1f1;
filter: dropshadow(color=#f1f1f1, offx=0, offy=0);
}
header > div:hover {
width: 920px;
}
header div:hover img {
left: 0px;
-webkit-filter: grayscale(0);
}
Here is what works:
http://codepen.io/jeremyzahner/full/cAEbv
Basically, i added a new container inside the "div" with class .inside. On that i do width:100%; height:100; position:relative; overflow:hidden;. Plus, i did remove the fixed height on the outer divs, since the header already holds that fixed height, it is not necessary to set it again.
It is a knonw "bug" of firefox that it treats display:table-cell; divs like that. I don't think they will fix it soon. So the best workaround (at least in my experience) is another inner wrapper like here.
CSS Modification:
header > div .inside {
position:relative;
width:100%;
height:100%;
overflow:hidden;
}
header > div {
background: url('./images/iron_man_bg.jpg');
width: 123.8px;
position: relative;
-webkit-transition: width .3s;
transition: width .3s;
display: table-cell;
border: 2px solid #fff;
overflow: hidden;
}
HTML Modification:
<div>
<div class="inside">
<img src="./images/ironman.png">
<span>Ironman</span>
</div>
</div>
This was tested in actual version of Chrome and Firefox (on Ubuntu).
Hope this helps
Related
I would like to add a link to an image that has an overlay applied to it. When users hover over the image they get an opaque overlay and text appear. This works great, however I also need users to be able to click that image and taken to a link.
I have pasted my code below - the overlay works but the link portion does not. I believe it's because the overlay is interfering. I tried changing the placement of the link but was unable to do so. I am able to make the '+' be the link, but ideally the entire image should link.
Any thoughts?
JSFiddle
.roomphoto:hover .img__description { transform: translateY(0); }
.roomphoto .img__description_layer { top: 30px; }
.roomphoto:hover .img__description_layer { visibility: visible; opacity: 1; }
.img__description_layer {
position: absolute;
bottom: 0;
left: 0;
right: 0;
color: #cdcbca;
visibility: hidden;
opacity: 0;
display: flex;
align-items: center;
justify-content: center;
transition: opacity .2s, visibility .2s;
}
.roomphoto {
height: 166px;
}
.img__description {
transition: .2s;
transform: translateY(1em);
z-index: 999;
}
.overlay {
position: relative;
}
.overlay:after {
position: absolute;
content:"";
top:0;
left:0;
width:100%;
height:100%;
opacity:0;
}
.overlay:hover:after {
opacity: .8;
}
.blue:after {
background-color: #1a3761;
}
.img__description a {
color: #fff;
}
.roomselect {
clear: both;
float: none;
width: 100%;
max-width: 1000px;
margin: 0px auto;
padding-top: 20px;
}
.roomselect img {
width: 100%;
margin-bottom: -10px;
}
.room3 {
width: 32%;
text-align: left;
float:left;
}
<div class="roomselect"><div class="room3">
<div class="roomphoto overlay blue">
<a href="http://www.google.com">
<img src="https://cdn.mos.cms.futurecdn.net/J9KeYkEZf4HHD5LRGf799N-650-80.jpg" alt="Image Text" />
</a>
<div class="img__description_layer">
<p class="img__description">
<span style="border-radius: 50%; width: 30px; height: 30px; padding: 0px 14px; border: 1px solid #fff; text-align: center; font-size: 36px;">+</span>
</p>
</div>
</div>
</div>
You need to rearrange your html in such a way that when you click on image, you are actually clicking on the anchor tag. I have made some changes to your html, let me know if these work. You might have to increase roomphoto height.
<div class="roomselect">
<div class="room3">
<a href="http://www.google.com">
<div class="roomphoto overlay blue">
<img src="https://cdn.mos.cms.futurecdn.net/J9KeYkEZf4HHD5LRGf799N-650-80.jpg" alt="Image Text" />
<div class="img__description_layer">
<p class="img__description"><span style="border-radius: 50%; width: 30px; height: 30px; padding: 0px 14px; border: 1px solid #fff; text-align: center; font-size: 36px;">+</span></p>
</div>
</div>
</a>
</div>
</div>
This question already has answers here:
How to overlay images
(11 answers)
Closed 5 years ago.
I want to highlight an image when a user hovers over it.
To do that, I'd like to put an overlay over everything else (or honestly, I'd be happy putting an overlay over everything including the image, and then putting something to brighten the image as well).
Is there anyway to do this without JS? I'm happy to use a JS solution if that's all that's available, but I was wondering if there was any CSS-only trickery that could manage to do this.
Example HTML would be like this:
<body>
<div>
<Other Elements />
<img src="...." />
</div>
</body>
Preferably everything would be darkened except the <img> tag.
You could use a sibling selector: .container img:hover ~ .overlay { background-color: rgba(0,0,0,0.8); }
body {
}
.container {
position: relative;
text-align: center;
margin: 10px auto 0;
padding-bottom: 10px;
}
.container .other {
display: inline-block;
margin: 20px 10px 10px;
width: 100px;
height: 100px;
background-color: darkorange;
z-index:1;
}
.container img {
display: inline-block;
margin: 10px 10px 10px;
z-index:1;
position: relative;
transition: all 300ms ease;
}
.overlay {
background-color: rgba(0,0,0,0);
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
pointer-events: none;
z-index:1;
transition: all 300ms ease;
}
.container img:hover ~ .overlay {
background-color: rgba(0,0,0,0.8);
}
.container img:hover {
z-index: 2;
transform: scale(1.1);
cursor: pointer;
}
<body>
<div class="container">
<div class="other"></div>
<div class="other"></div>
<img src="https://picsum.photos/100/100?image=2" />
<div class="other"></div>
<img src="https://picsum.photos/100/100?image=4" />
<div class="other"></div>
<img src="https://picsum.photos/100/100?image=6" />
<img src="https://picsum.photos/100/100?image=8" />
<div class="overlay"></div>
</div>
</body>
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 this pen: http://codepen.io/helloworld/pen/VYWGbz
I have set these classes in my production code and they cause IE 11 to NOT render somehow the left black border WHEN the drawer is opened.
When I remove the vertical-alignment with table/table-cell as display property the error disappears... (In Chrome its fine...)
What choice do I have else to vertically align the drawer`s glyphicon/span instead of using table on parent and table-cell on child to make vertical align possible with middle?
Note: The drawer/sidebar always have a height of 100% recieved by its parent.
.drawer-left-trigger{
display:table;
}
.drawer-left-trigger > span{
display:table-cell;
vertical-align:middle;
}
HTML
<div id="idtView">
<div style="height:100%;background:blue;" class="col-xs-3">
test1
</div>
<div style="height:100%;background:yellow;" class="col-xs-4">
test2
</div>
<div id="availableSidebarColumn" style="background:orange;padding:0;height:100%;" class="col-xs-1">
<div class="drawer-wrapper">
<div id='drawer-left' class='closed'>
<div class='drawer-left-trigger'>
<span class='glyphicon glyphicon-chevron-left'></span>
</div>
<div class='drawer-left-content'>
<div style="background:orange;;" id="availableCommandsPagerNavigation">
<span class="previous disabled glyphicon glyphicon-chevron-left availableOptionsArrow availableOptionsPagerArrow"></span>
<span class="glyphicon glyphicon-chevron-right availableOptionsArrow availableOptionsPagerArrow"></span>
</div>
<div style="background:gray;" id="availableCommandsContainer">
contentcontentcontentcontentcontentcontentcontent contentcontent content
</div>
</div>
</div>
</div>
</div>
<div style="height:100%;background:pink;" class="col-xs-4">
test2
</div>
</div>
CSS
/*new stuff*/
*{
box-sizing: border-box;
}
.drawer-wrapper{
margin: 0 200px;
display: inline-block;
}
/*The left drawer*/
#drawer-left{/*set a container with the total width of both the container and the trigger*/
position: relative;
height: 100%; width: 205px;
overflow: hidden;
transition: all .35s ease-in-out;
}
#drawer-left:after{/*this will the right border, when the content will be pushed out*/
content: '';
position: absolute;
right: 0; top: 0; bottom: 0;
border-right: 1px solid #000;
}
.drawer-left-trigger{
/*set the triggers width here, borders etc.*/
position: absolute;
top: 0; bottom: 0; right: 100%;
margin-right: -25px;/*bring it back inside the wrapper*/
width: 25px;
background:yellow;
/*some styling stuff*/
cursor: pointer;
text-align: center;
font-size: 24px;
line-height: 100%;
}
.drawer-left-trigger > span{
transform: rotate(180deg);
transition: all .35s ease-in-out;
}
#drawer-left.closed .drawer-left-trigger > span{
transform: rotate(0);
}
#drawer-left.closed .drawer-left-trigger{
/*this will push the trigger on the right side*/
left: auto;
right: 25px;
}
.drawer-left-content{
/*this is the container for the header and content*/
position: absolute;
top: 0; bottom: 0; right: 0; left: 24px;/*the triggers width(+-1px from the border)*/
}
#drawer-left.closed .drawer-left-content{
/*this will push the content out*/
left: 100%;
right: -100%;
}
.drawer-left-trigger,
.drawer-left-content{
border-left: 1px solid #000;
border-bottom: 1px solid #000;
border-top: 1px solid #000;
transition: all .35s ease-in-out;
}
JS
$(function () {
/*the left one*/
$('.drawer-left-trigger').click(function(){
$(this).parent().toggleClass('opened closed');
});
});
You could use FlexBox.
http://css-tricks.com/snippets/css/a-guide-to-flexbox/
Browser Support
http://caniuse.com/#feat=flexbox
You can use translateY, and position relative.
.drawer-left-trigger > span{
transition: all .35s ease-in-out;
transform: rotate(180deg) translateY(-50%);
position: relative;
top: 50%;
}
If the .drawer-wrapper is the only element on the page, consider setting its height to 100% instead of 500px by adding
html,body,.drawer-wrapper {
height: 100%;
}
If you need to add some navigation bar on top, calculate drawer's height by calc(100% - 50px) where 50px is the height of navigation bar.
Working version
http://codepen.io/antraxis/pen/yyoNpg
I have a carousel with images/descriptions in it and my height:auto does not work properly. Height computed is too big
JSBin: JSBin
I can only guess that this is because my .shadow class which is relative with height 150px.
Please take a look on it.
Edit: code as requested
This is result of one item from carousel
<div class="carousel2">
<div class="carousel">
<div class="owl-carousel owl-theme" id="owl-example" style=
"opacity: 1; display: block;">
<div class="owl-wrapper-outer">
<div class="owl-wrapper" style=
"width: 4092px; left: 0px; display: block; -webkit-transform: translate3d(0px, 0px, 0px); -webkit-transition: all 200ms ease; transition: all 200ms ease;">
<div class="owl-item" style="width: 341px;">
<div class="pc">
<div class="c">
<img alt="image" src=
"http://www.ramp-alberta.org/_system/ThumbnailCache/UserFilesImageAug~16~Site~1_004jpg.300.-1.-1108757834.jpg">
<div class="shadow">
<div class="description">
Event1
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
And here is my css
.carousel2
{
overflow: hidden;
/* height:400px; */
background-color: #344754;
}
.carousel
{
width: 1364px;
float: left;
height: auto;
}
.shadow
{
position: relative;
bottom: 150px;
left: 0;
right: 0;
background: rgba(222,103,21,0.7);
filter: progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr='#B2344855', endColorstr='#B2344855');
height: 150px;
vertical-align: middle;
z-index: 1;
width: 100%;
text-align: center;
}
.pc{
/* border: blue 1px solid; */
width: 1%;
display: table;
margin: auto;
height: auto;
overflow: hidden;
}
.c
{
overflow: hidden;
}
.description
{
padding-top: 15px;
font-family: "FSRufus";
font-size: 30px;
font-weight: bold;
color: white;
}
.owl-item
{
overflow: hidden;
}
You should give class carousel2 a min-height so that CSS will know till what it needs to scale image. Try to use exact size images to save processing time. Also remove height from class Shadow. This should help.