I am working on a page which comprises of the divs floated on same direction with each having specified width so as to create a grid. I was trying the -webkit scale effect in order to have a zooming effect on the any hovered div along with other divs having their opacity reduced.
The problem arises when among the divs stacked together, when the div that comes first in order is hovered, it is partially overlapped the its successor div(having reduced opacity) due to zooming
here's an example code
html
<div id="div1" class="tile">Content 1</div>
<div id="div2" class="tile">Content 2</div>
<div id="div3" class="tile">Content 3</div>
css
.tile{
width:100px;
margin:6px;
float:left;
height:100px;
margin-right:0px;
margin-bottom:0px;
-webkit-transition: all .1s ease-in-out .1s;
-moz-transition: all .1s ease-in-out .1s;
}
.tile:hover{
-webkit-transform: scale(1.1);
-moz-transform: scale(1.1);
-moz-box-shadow: 0 0 3px 1px #fff;
-webkit-box-shadow: 0 0 3px 1px #fff;
box-shadow: 0 0 3px 1px #333;
}
and jquery
function tile_mouseover()
{
$(this).siblings('.tile').stop(true,true).animate({'opacity':'0.5'},300);
$(this).stop(true,true).animate({opacity:1},200)
}
On implementing the above the code,
when div1 is hovered, its scaled, and is overlapped by div2.
Any possible solutions?
I think this should work.
.tile {
position: relative;
}
.tile:hover{
z-index:2;
}
you're declaring a margin twice on your .tile class, fix it like this:
.tile{
width:100px;
margin:6px;
float:left;
height:100px;
-webkit-transition: all .1s ease-in-out .1s;
-moz-transition: all .1s ease-in-out .1s;
}
Related
All I want is to have the button in the second box displayed as a block element so that it expands to fill the container -- but when I set the button element to display:block -- it overflows the container (parent), see the following:
http://jsfiddle.net/MgcDU/7747/
Any ideas? What am I missing?
My CSS:
a:link { color:#0040FF;text-decoration:none; }
a:visited { color:#0040FF; }
a:hover { background-color:#82B6EA;color:#FFFFFF;text-decoration:none; }
a:active { color:#0040FF; }
body { color:black;font-style:normal;font-size:10pt;font-family:Arial, Helvetica, sans-serif;padding:0;margin:0; }
.body_1 { margin-top:10px;margin-left:20px;margin-right:20px;margin-bottom:10px; }
.grid_1 { margin:8px 0 0 0;padding:0;overflow:hidden; }
.grid_1_left { float:left;width:240px;margin:0;padding:0; }
.grid_1_right { margin:0 0 0 245px;padding:0 0 0 8px; }
.grid_1_right_bld { margin:0 0 0 245px;padding:0 0 0 8px;border-left:2px #AAAAAA dotted; }
.btn, a.btn
{
background-color:#D3D7D7;color:#333333;display:inline-block;padding:6px 12px;margin-bottom:0;text-align:center;white-space:nowrap;vertical-align:middle;
cursor:pointer;border:1px solid transparent;border-color:#D3D7D7;
-webkit-transition:border-color 0.3s ease-out, background-color 0.3s ease-out;
-moz-transition:border-color 0.3s ease-out, background-color 0.3s ease-out;
transition:border-color 0.3s ease-out, background-color 0.3s ease-out;
}
.btn:hover,
.btn:focus,
.btn:active { background-color:#AEB1B1;color:#333333;border-color:#AEB1B1;text-decoration:none;outline:0; }
.btn_success, a.btn_success { color:#FFFFFF;border-color:#64b92a;background-color:#64b92a; }
.btn_success:hover,
.btn_success:focus,
.btn_success:active { color:#FFFFFF;border-color: #50a118;background-color:#50a118; }
.btn_lg { padding:8px 14px;font-size:12pt; }
.btn_block { display:block;margin:0;padding:0;width:100%; }
.box_1 { border:1px solid #5C6666;margin:0; }
.box_1_body { background-color:#FFFFFF;border-top:1px solid #5C6666;margin:0;padding:6px; }
.box_1_title { background-color:#5C6666;color:#FFFFFF;margin:0;padding:6px;text-align:center; }
My HTML
<div class="body_1">
<div class="grid_1">
<div class="grid_1_left">
<div class="box_1">
<div class="box_1_title">Box 1</div>
<div class="box_1_body">
Stays in the Box
</div>
</div>
<br>
<div class="box_1">
<div class="box_1_title">Box 2</div>
<div class="box_1_body">
Does NOT stay in the Box
</div>
</div>
</div>
<div class="grid_1_right">
main body content
<br>
Btn 1
Btn 2
<br><br>
Note how the buttons can align without being stacked (ie: inline-block) must remain in .btn selector class
</div>
</div>
</div>
This is because you are setting the width on .btn to 100% and you also have padding, which will add the padding on top of the 100% width. This is making the block spill out of the parent element.
What you want is this (display:inline-block; has changed to display:block;):
.btn,
a.btn {
background-color: #D3D7D7;
color: #333333;
display: block;
padding: 6px 12px;
margin-bottom: 0;
text-align: center;
white-space: nowrap;
vertical-align: middle;
cursor: pointer;
border: 1px solid transparent;
border-color: #D3D7D7;
-webkit-transition: border-color 0.3s ease-out, background-color 0.3s ease-out;
-moz-transition: border-color 0.3s ease-out, background-color 0.3s ease-out;
transition: border-color 0.3s ease-out, background-color 0.3s ease-out;
}
and then remove the width:100% from .btn_block
EDIT
Here is an updated jsfiddle
http://jsfiddle.net/932Fa/
It is all about the BOX-SIZING CSS property. The new standards seem counter-intuitive to me. Bootstrap and other frameworks will set everything to {box-sizing: border-box;}, but when you drop to your own CSS, the default these days is {box-sizing: content-box;}.
Either deal with your Paddings & Borders explicity, or just put
{box-sizing:border-box;}
at the top of your CSS and then boxes will 'behave'.
Problem solved !!
Added the following to get higher CSS specificity and everything works as it should now.
.btn_block, a.btn_block { display:block;width:100%;padding-right:0;padding-left:0; }
See updated JSFiddle: http://jsfiddle.net/U8YhJ/1/
I'm almost afraid to ask this question because it seems like such an obvious one, but I just can't find a clear answer, so at the risk of tarnishing my non-existant reputation, here goes:
Is there a way to add an expanding CSS inner-border to an image on hover, without affecting the size of the image?
Here is my code as close as I can get on my own:
CSS
* {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
-ms-box-sizing: border-box;
box-sizing: border-box;
}
.media_item_container img {
border: 3px solid #00205f;
-webkit-transition: all .3s ease;
-moz-transition: all .3s ease;
-o-transition: all .3s ease;
-ms-transition: all .3s ease;
transition: all .3s ease;
}
.media_item_container img:hover {
border: 10px solid #00205f;
}
.media_item_container a
{
font-weight:bold;
color:#000;
text-decoration:none;
font-size:13px;
}
.media_item_container a:hover
{
color:#fff;
}
HTML
<body bgcolor="#999999">
<div class="media_item_container">
<div class="media_item_text">
<a href="#"><img src="http://lorempixel.com/output/business-q-c-158-158-5.jpg" width="158" height="158" class="media_item_thumb" />
<h3>E-Brochure: <em>Printable e-brochure</em></h3>
DOWNLOAD »</a>
</div>
</div>
</body>
http://jsfiddle.net/aKedV/
Just trying to determine if there is any way to do it without the image scaling down as the border size increases (I basically understand why this is happening, just can't seem to come up with a solution on my own).
And I should clarify when I ask if there is a way to do this, I assume there must be some way to do this, but I would love to know if there is a relatively easy way.
Thanks so much!
You can use outline instead of border.
outline:3px solid red;
outline-offset:-3px; //keeping it inside
and on hover
outline:10px solid red;
outline-offset:-10px;
Fiddle
Mate this is the solution that I came up with. Had to Change some HTML and CSS up but this is my shot at it. Hope this helps mate, Cheers
http://jsfiddle.net/aKedV/3/
HTML:
<body bgcolor="#999999">
<div class="media_item_container">
<div class="media_item_text">
<a href="#">
<div class="border" style="background: url(http://lorempixel.com/output/business-q-c-158-158-5.jpg);">
</div>
<h3>E-Brochure: <em>Printable e-brochure</em></h3>
DOWNLOAD »</a>
</div>
</div>
CSS:
.border {
-webkit-transition: all 500ms linear;
-o-transition: all 500ms linear;
-moz-transition: all 500ms linear;
-ms-transition: all 500ms linear;
-kthtml-transition: all 500ms linear;
transition: all 500ms linear;
width: 158px;
height: 158px;
}
.border:hover {
-webkit-box-shadow: inset 0px 0px 2px 10px #00205f;
box-shadow: inset 0px 0px 2px 10px #00205f;
}
.media_item_container a
{
font-weight:bold;
color:#000;
text-decoration:none;
font-size:13px;
}
.media_item_container a:hover
{
color:#fff;
}
I'm trying to make a original tumblr blog theme. This is my first time writing one from scratch, although CSS is not new to me. Z-indexes, however...
In short, on each post, a menu (like, reblog etc buttons...) becomes visible when the cursor hovers over a post. Apologies if my code looks messy.
header is the highest element on the entire page. Everything within h2 is the button menu, so it should be under header at all times.
#top header{
font-family:"Open Sans Condensed", sans-serif;
font-size:3.5em;
padding:0px;
margin-top:-8px;
height:72px;
text-transform:uppercase;
color:#fff;
background-color:{color:Base};
width:100%;
text-align:center;
-webkit-box-shadow: 1px 1px 3px 0px rgba(0, 0, 0, .6);
box-shadow: 1px 1px 3px 0px rgba(0, 0, 0, .6);
-webkit-transition: all 3s ease-in-out;
-moz-transition: all 3s ease-in-out;
-ms-transition: all 3s ease-in-out;
-o-transition: all 3s ease-in-out;
transition: all 3s ease-in-out;
}
#post h2 {
float:left;
width:auto;
margin:5px 4px -130px -10px;
opacity:0.0;
position:relative;
z-index:2;
padding-left:5px;
font-family:"Calibri", sans-serif;
text-decoration:none;
-webkit-transition: all .6s ;
-moz-transition: all .6s ;
-ms-transition: all .6s ;
-o-transition: all .6s ;
transition: all .6s ;
}
#post h2 a{
color: #fff;
font-family:calibri;
}
#post h2 .item{
width:20px;
color:#fff;
background-color:#5C5C5C;
margin-bottom: 4px;
padding:3px;
-webkit-box-shadow: 1px 1px 3px 0px rgba(0, 0, 0, .6);
box-shadow: 1px 1px 3px 0px rgba(0, 0, 0, .6);
-webkit-border-radius: 4px;
border-radius: 4px;
text-align:center;
-webkit-transition: all .6s ;
-moz-transition: all .6s ;
-ms-transition: all .6s ;
-o-transition: all .6s ;
transition: all .6s ;
}
#post h2 .item:hover{
background-color:{color:Post Accent};
-webkit-transition: all .6s ;
-moz-transition: all .6s ;
-ms-transition: all .6s ;
-o-transition: all .6s ;
transition: all .6s ;
}
#post h2 {
color:#ccc;
margin-left:0px;
opacity:1.0;
z-index:2!important;
-webkit-transition: all .6s ;
-moz-transition: all .6s ;
-ms-transition: all .6s ;
-o-transition: all .6s ;
transition: all .6s ;
}
I appreciate any help! Also feel free to give me any tips related to what you see above.
Thanks!
Edit:
HTML Markup for an example photoset post:
<div id="bin">
<div id="post">
<h2> <!-- permalink !-->
<div class="item" style="max-width:auto; width:auto;">{NoteCount} ♫</div>
<div class="item" style="padding-top:5px; padding-bottom:0px;">{LikeButton}</div>
<div class="item">{ReblogButton}</div>
<div class="item">∞</div>
</h2>
<div id="photoset">
<div class="photoset">
{Photoset}
</div>
</div>
{block:Caption}
{Caption}
{/block:Caption}
<div id="date">
{TimeAgo}
</div>
</div>
</div>
LIVE PREVIEW
http://pianotheme.tumblr.com/
Apply position:relative; to the #top header element with a z-index:999;.
Also, you want to make sure you don't have multiple DOM elements with the same id value. They should be unique within the DOM...otherwise, you can get some strange behavior.
If the issue is just that the buttons and things overlap the top header when you scroll, simply put a high z-index on the #top element. E.g.
#top {
z-index: 1000;
}
You have not got a closing } on your top CSS declaration
You do not have any z-index declared in your header CSS. You should set z-index this and ensure it has a higher value to what is currently set to your h2. To ensure that it is always on top you could give it a value of 1000, for testing purposes.
z-index works only on non static elements. You do have position: relative and z-index: 2 on h2 but it won't work as nothing else has non-static positioning. What effect are you expecting from h2? above which element do you want it to be?
Also, bu default absolute / relative / static will always stay above static element at same level.
I'm trying to create a transition from a white background to an image background. This way when the viewer hovers over a section it goes from plain to styled.
Here's my current code:
div.camp {
background: #FFFFFF;
border: 1px solid #CCCCCC;
border-radius: 8px;
padding: 8px;
transition: all 1s linear 0s;
}
div.camp:hover {
background: #EFFFD5 url("http://www.alpinejosh.com/host/sp/images/camp.png");
background-position: center bottom;
background-repeat: repeat-x;
border: 1px solid #CECECE;
}
Here's the page this code is on: http://www.summitpost.org/eldorado-peak/150316#chapter_7
From what I understand it's easy to have background colors transition. But it seems as though background images are not supported for transition.
Unfortunately you cannot use transition on background images in the way you've specified. You can see the W3C list of animation property types here.
You could potentially lay your white background over the top, then animate its opacity on hover (to show the image beneath).
Code Sample
You could obviously make this prettier. I've just cobbled something together to give you an idea.
div.camp {
border: 1px solid #CCCCCC;
background: #EFFFD5 url("http://www.alpinejosh.com/host/sp/images/camp.png");
background-position: center bottom;
background-repeat: repeat-x;
border-radius: 8px;
position: relative;
}
div.camp-overlay {
padding: 8px;
border-radius: 8px;
position: absolute;
z-index:50;
width: 100%;
height: 100%;
background:white;
-webkit-transition: all 1s ease-in-out;
-moz-transition: all 1s ease-in-out;
-o-transition: all 1s ease-in-out;
transition: all 1s ease-in-out;
}
div.camp-overlay:hover {
background: rgba(255,255,255,0); /* use opacity for older browsers*/
}
HTML for the above CSS
<div class="camp">
<div class="camp-overlay"></div>
</div>
JSFiddle of the above
http://jsfiddle.net/p7mcy/
What you could do is make two div elements, one on top of the other, and fade top div out on hover.
<div class="wrapper">
<div class="image"></div>
<div class="white-bg"></div>
</div>
.wrapper{position:relative;}
.image, .white-bg{position:absolute; top:0; left:0; width:100px; height:50px;}
.image{background:red;}
.white-bg{background:white; z-index:9999; -webkit-transition:opacity 0.3s linear; opacity:1;}
.white-bg:hover{opacity:0;}
Should work
fiddle: http://jsfiddle.net/b46z8/5/
I am trying to tint images onHover. I have the css working but some of the images which have rounded edges or don't completely fill the parent show the black background:
(The far left has the mouse over it)
How can hide the black so only the img is tinted?
Here is my css:
.thumb {
width:150px;
height:150px;
margin: 0px 5px 14px 14px;
float:left;
display:inline;
background: black;
overflow:hidden;
cursor: pointer;
/*border: 2px solid #00A3C6; */
}
.thumb img {
display: block;
-webkit-transition: all 0.25s linear;
-moz-transition: all 0.25s linear;
-ms-transition: all 0.25s linear;
-o-transition: all 0.25s linear;
transition: all 0.25s linear;
}
.thumb:hover img {
opacity: 0.7;
}
If the image has rounded corners, you can use border-radius in your css to set rounded corners of the "tint" container.
If the actual image has a white border... you're kind of out of luck. You can crop images but you don't have any way to doing this dynamically for any kind of image.
How can hide the black so only the img is tinted?
Try removing background: black from .thumb ?
P.S. display: inline is also not needed there