I am new in css sprites, i can't understand how to make my image changes in hover. I want my only one image to be change which is "Scroll To Top" website. I am trying this coding but it was not working. Images links are given below:
http://imgur.com/TM6kIqm
#toTop {
background:url(img/scroll-to-top-2.png)no-repeat;
background-position:0px -50px;
width:50px;
height:50px;
padding: 5px 3px;
overflow:hidden;
position: fixed;
bottom: 20px;
right: 20px;
display: none;
cursor:pointer;
z-index:600;
text-decoration:none;
border:medium none;
}
#toTop:hover {
background:url(img/scroll-to-top-2.png)no-repeat left -29px;
width:50px;
height:50px;
padding: 5px 3px;
overflow:hidden;
position: fixed;
display: none;
}
There are a few problems here.
First, you have #toTop set to display: none, so it will never be shown, with any background.
Second, you seem to be trying to move the background image to the left on hover, rather than up/down, the way the image is built.
Third, with padding, in most browsers your height/width will be thrown off unless you use box-sizing: border-box; (which includes padding and borders in the height and width).
So (eliminating redundant properties):
#toTop {
background: url(http://i.imgur.com/TM6kIqm.png) no-repeat;
background-position: 0px -50px;
width: 50px;
height: 50px;
padding: 5px 3px;
-moz-box-sizing: border-box;
box-sizing: border-box;
overflow: hidden;
position: fixed;
bottom: 20px;
right: 20px;
cursor: pointer;
z-index: 600;
text-decoration: none;
border: none;
}
#toTop:hover {
background-position: 0 0;
}
example: http://codepen.io/paulroub/pen/vDBaA
Related
Considering the next code:
.test {
position: relative;
padding: 0;
margin: 0;
border: 0;
background: initial;
font-size: 11px;
border: 1px solid black;
margin-left: 20px;
}
.test::after {
content: '';
position: absolute;
top: 50%;
left: 0;
width: 100%;
height: 1px;
background: red;
}
<button class="test">Some Text Content</button>
In Chrome it's rendered like (hot it is required):
In Safari it's rendered like:
So, in Safari it's not vertically centered and the block has different size.
The main question is how to center it vertically in Safari?
The secondary question is how to make blocks absolutely similar?
I tried display: flex; align-items: center;, vertical-align: center;, changing line-height – nothing from that seemed to work...
.btn {
border:1px solid #000;
box-sizing:border-box;
color:#000;
display:inline-block;
font:1rem/1.5 sans-serif;
height:2rem;
padding:0 1rem;
text-align:center;
vertical-align:middle;
width:auto;
}
The nav buttons sit on top of the image title div. Both drop down on hover. When going to the next image, the nav buttons are at the correct location, but when you click on the previous, the whole nav screen shifts to the bottom right!
nav {
position: absolute;
width: 100%
height: 20px;
padding-bottom: 2px;
z-index: 1;
float: right;
margin-top: -20px;
transition: margin-top 200ms ease-in;
background: black;
opacity: 0.4;
right: 1px;
}
.title {
position: absolute;
width: 85%;
height: 20px;
padding-bottom: 2px;
margin-top: -25px;
transition: margin-top 200ms ease-in;
background: black;
color: white;
opacity: 0.6;
}
.title-text {
float: left;
padding-left: 5px;
}
.slides:hover .title {
margin-top: 0px;
}
Here is link to a fiddle.
I fixed this part but code itself is clumsy
anyway still here is example : jsfiddle
first of all you forgot ";" in .nav { between height and width
secondly dont use position: absolute and float it exclude each other
try to connect similiar classes like your buttons
.btn-prev,
.btn-next{
color: black;
background:white;
border: 2px solid white;
margin: 0px 5px 0px 0px;
cursor: pointer;
padding: 0px 5px 0px 5px;
display: inline-block;
}
Quick explain, I set text-align on .nav element so buttons would be set on right side inside .nav and .btn-* for display: inline-block; (default
display: block; so it would behave similiar like text.
I'm building a MDI WEB application, and have a window created made by a article element, with a header and a section for content. Since it's an MDI app, the article is set to absolute, so it can overlap other windows. I need a scrollbar to appear in the content section, but not in the header.
<article id="win3">
<header> … </header>
<section> … </section>
</article>
CSS:
article {
position: absolute;
min-width: 500px;
width: 918px;
margin: 0px;
padding: 0px;
overflow: hidden;
background-color: white;
border-style: ridge;
border-color: #ddd;
border-width: 4px;
}
article>section {
/* reduce diameter of rounded corner to match the inside curve of the border */
border-radius: 10px;
-moz-border-radius: 10px;
display: block;
overflow: auto;
border: none;
width: 100%;
background-color: white;
padding: 10px 10px 10px 20px;
min-height: 50px;
height: 100%;
}
It looks like the overflow: auto is ignored in Firefox (v 22), but the scrollbar does appear in Chrome.
Any ideas on how I make the scrollbar reliably when needed in the content section?
Your key problem is with padding value, so you need to set width decreasing some percentage in your article>section
article>section {
/* reduce diameter of rounded corner to match the inside curve of the border */
border-radius: 10px;
-moz-border-radius: 10px;
display: block;
overflow: auto;
border: none;
/*width: 100%;*/
width: calc(100% - 30px) /* or set fixed width percentage like 90% */
background-color: white;
padding: 10px 10px 10px 20px;
min-height: 50px;
height: 100%;
}
article {
position: absolute;
min-width: 500px;
width: 918px;
margin: 0px;
padding: 0px;
overflow: hidden;
background-color: white;
border-style: ridge;
border-color: #ddd;
border-width: 4px;
height:100px;
}
article>section {
/* reduce diameter of rounded corner to match the inside curve of the border */
overflow:auto;
height:100%;
border:none;
display: block;
padding: 10px 10px 10px 20px;
min-height:50px;
}
I'm trying to build a tag system with 'negative border radius' (I lack a better description).
I use :after and :before to create some faux border the 'bends outside'. It worked well, but there is some strange behaviour in MSIE. Normally I have top:5px on the :after and :before, but in IE I have to add an extra pixel (results in top: 6px) (See in IE8: the horizontal lines to the left and right should not be visible)
What could that be?
http://jsfiddle.net/rhGZw/3/
<div class="test"><div>foo</div></div>
body {
background: gold;
margin: 10px;
}
.test {
display: inline-block;
height: 30px;
overflow: hidden;
}
.test > div {
background: white;
border-top-left-radius: 5px;
border-top-right-radius : 5px;
height: 20px;
padding: 5px;
display: inline-block;
}
.test:before {
content: '';
width: 5px;
height: 20px;
position: relative;
top: 5px;
margin-right: -5px;
background: none;
border-color: white;
border-style: solid;
border-width: 0px;
border-bottom-width:5px;
border-right-width:5px;
border-bottom-right-radius: 10px;
display: inline-block;
vertical-align: middle;
z-index: -1;
}
.test:after {
content: '';
width: 5px;
height: 20px;
position: relative;
top: 5px;
margin-left: -5px;
background: none;
border-color: white;
border-style: solid;
border-width: 0px;
border-bottom-width:5px;
border-left-width:5px;
border-bottom-left-radius: 10px;
display: inline-block;
vertical-align: middle;
z-index: -1;
}
I managed to get the error by myself. It was the vertical-align:middle with the :after and :before which caused the 1px offset
The white borders are visible in Firefox and Opera too, not just IE. However, they blend into the border-radius.
It's easy to see at http://jsfiddle.net/CrxQG/ and http://jsfiddle.net/CrxQG/1/ with black border color and border-radius removed, respectively.
I have a problem with css popup. I am hidden some content in span tags and show it when I hover over a text. But there is a overlap and the text in the second line is overlapping the popup. And the border for the popup is messed up. The content is on this link. And I am using following css:
.rest-cat
{
clear: both;
padding: 3px 40px 0 0!important;
width: 600px;
}
.rest-menuitem
{
position: static;
float: left;
width: 254px;
padding: 3px 5px 0 0!important;
border-top: 1px dotted #DDD;
}
.dishname{
position: absolute;
z-index: 0;
float: left;
width: 229px;
}
.dishprice{
position: relative;
float: right;
width: 25px;
}
.product
{
width: 600px;
padding: 0px 0px 20px 20px!important;
}
.dishname span
{
display: none;
text-decoration: none;
}
.dishname:hover
{
overflow: hidden;
text-decoration: none;
}
.dishname:hover span
{
display: block;
position: static;
top: 0px;
left: 170px;
width: 320px;
margin: 0px;
padding: 10px;
color: #335500;
font-weight: normal;
background: #e5e5e5;
text-align: left;
border: 1px solid #666;
z-index: 200;
}
Is there a easy fix for this? I already tried using position: relative; and added z-index to all the CSS tags. They didn't work and I am stuck on it for a day.
The reason your popups are being clipped is because of this CSS:
.dishname:hover {
overflow: hidden;
}
Removing that would be a good place to start.
Next, z-index only affects elements with a position property other than static. Use relative and they will render the same but the z-index will have an effect.
After that there are a lot of different things that could be affecting the layering I would start like #Michael Rader said by cleaning up your HTML, you have a lot of unnecessary wrappers.