I am having issues with text moving them I hover over the element. It is working fine until you hover over it.
So just to clarify you run the mouse over the text and the background colour and everything changes correctly, just the text moved higher than origional text.
This is the CSS code I have for this element:
#top_login_panel ul.menu_topPanel li.item-8 {
background: url("../images/menu/top-panel-login-bg.png") no-repeat scroll 0 0 hsla(0, 0%, 0%, 0);
height: 43px;
width: 145px;
}
#top_login_panel ul.menu_topPanel li.item-8 a {
width: 145px;
}
#top_login_panel ul.menu_topPanel li.item-8 a:hover {
background-image: url("../images/menu/top-panel-login-bg1.png") !important;
background-position: center center !important;
background-repeat: no-repeat !important;
color: hsl(0, 1%, 25%);
margin-left: -3px;
margin-top: -8px;
width: 114px;
}
#top_login_panel ul.menu_topPanel li.item-8 a {
display: block;
font-size: 12px;
padding: 22px 0 0 35px;
}
Can you please advice how to resolve this issue?
Thanks
try this.,
#top_login_panel ul.menu_topPanel li.item-8 a:hover {
background-image: url("../images/menu/top-panel-login-bg1.png") !important;
background-position: center center !important;
background-repeat: no-repeat !important;
color: hsl(0, 1%, 25%);
}
#top_login_panel ul.menu_topPanel li.item-8 a {
display: block;
font-size: 12px;
padding: 22px 0 0 35px;
margin-left: -3px;
margin-top: -8px;
width: 114px;
}
I changed the margin property to a tag
The problem is that the hover block of CSS code has properties and values that the normal state doesn't have so it moves as the new properties are applied. Let the color be the only difference if you don't want it to move.
li.item-8 a {
background-image: url("../images/menu/top-panel-login-bg1.png") !important;
background-position: center center !important;
background-repeat: no-repeat !important;
margin-left: -3px;
margin-top: -8px;
width: 114px;
}
li.item-8 a:hover {
background-image: url("../images/menu/top-panel-login-bg1.png") !important;
background-position: center center !important;
background-repeat: no-repeat !important;
color: hsl(0, 1%, 25%);
margin-left: -3px;
margin-top: -8px;
width: 114px;
}
<ul>
<li class="item-8">One</li>
<li class="item-8">One</li>
<li class="item-8">One</li>
<li class="item-8">One</li>
</ul>
Thanks #Sathish S I used the moving of the elements but then just placed the padding in a different location and that worked.
#top_login_panel ul.menu_topPanel li.item-8 a {
display: block;
font-size: 12px;
margin-left: -3px;
margin-top: -12px;
width: 114px;
}
#top_login_panel ul.menu_topPanel li.item-8 a:hover {
background-image: url("../images/menu/top-panel-login-bg1.png") !important;
background-position: center center !important;
background-repeat: no-repeat !important;
color: hsl(0, 1%, 25%);
}
#top_login_panel ul.menu_topPanel li.item-8 a {
padding: 31px 0 0 35px;
}
Related
how can I make something like this, but on all 4 sides of the border (top, right, left, bottom)?
.zigzag {
position: relative;
padding: 4px 4px 20px 4px;
background: lightgray;
}
div>div {
text-align: center;
height: 200px;
}
.zigzag:after {
background: linear-gradient(-45deg, #ffffff 16px, transparent 0), linear-gradient(45deg, #ffffff 16px, transparent 0);
background-position: left-bottom;
background-repeat: repeat-x;
background-size: 32px 32px;
content: " ";
display: block;
position: absolute;
bottom: 0px;
left: 0px;
width: 100%;
height: 32px;
}
<div class="zigzag">
<div>ZigZag</div>
</div>
I am building a vertical timeline as a < ul > with the < li >s as events. This is the intent:
I've customized the bullets easily enough, and I made the vertical line with a background-gradient; the one thing I haven't been able to do is terminate the vertical line at top and bottom.
So far, it looks like this:
My SCSS code:
ul.timeline {
list-style: none;
color: red;
font-size: .8em;
/* Permalink - use to edit and share this gradient: http://colorzilla.com/gradient-editor/#ffffff+0,ffffff+5,d8d8d8+6,d8d8d8+7,ffffff+8,ffffff+100 */
background: #ffffff; /* Old browsers */
background: -moz-linear-gradient(left, #ffffff 0%, #ffffff 1px, #d8d8d8 2px, #d8d8d8 3px, #ffffff 4px, #ffffff 100%); /* FF3.6-15 */
background: -webkit-linear-gradient(left, #ffffff 0%,#ffffff 1px, #d8d8d8 2px, #d8d8d8 3px, #ffffff 4px,#ffffff 100%); /* Chrome10-25,Safari5.1-6 */
background: linear-gradient(to right, #ffffff 0%,#ffffff 1px, #d8d8d8 2px, #d8d8d8 3px, #ffffff 4px,#ffffff 100%); /* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffff', endColorstr='#ffffff',GradientType=1 ); /* IE6-9 */
background-position: 29px 0;
li {
&::before {
content: "\26AB";
font-size: 1.3em;
color: #d8d8d8;
display: inline-block;
width: 1em;
margin-left: -1em;
vertical-align: middle;
}
a {
color: black;
text-decoration: underline;
}
}
}
My HTML code:
<ul class="timeline">
<li>asd as</li>
<li>werwer we</li>
</ul>
I know I can scrap the whole custom-bullet and background-gradient css and do this with background-images, I was just hoping to find a css-only solution.
You can use pseudo-elements for this, one for circle and other one for the line, and :not(:last-child) so you don't set line on last element.
ul {
list-style: none;
}
li {
position: relative;
padding: 10px;
}
li a {
color: gray;
}
li:before {
content: '';
width: 16px;
height: 16px;
border-radius: 50%;
background: #D8D8D8;
position: absolute;
left: -15px;
top: 50%;
transform: translateY(-40%);
}
li:not(:last-child):after {
content: '';
width: 2px;
height: 100%;
background: #D8D8D8;
position: absolute;
left: -8px;
top: 50%;
}
<ul class="timeline">
<li>asd as</li>
<li>werwer we</li>
<li>werwer we</li>
</ul>
Method using background-gradient...
ul.timeline {
list-style: none;
color: red;
font-size: .8em;
position: relative;
}
.timeline::before {
position: absolute;
content: "";
display: block;
height: 80px;
width: 30px;
top: 6px;
left: 0;
background: radial-gradient(circle, grey 20%, transparent 20%);
background-size: 50px 25px;
}
.timeline::after {
position: absolute;
content: "";
display: block;
top: 8px;
left: 24px;
height: 70px;
width: 1px;
background: grey;
}
.timeline li {
padding: .5em;
}
a {
color: black;
text-decoration: underline;
}
<ul class="timeline">
<li>asd as</li>
<li>werwer we</li>
<li>werwer we</li>
</ul>
Sprite rollover images not displaying.
The goal is to have a row of icons with a rollover controlled by CSS.
Currently, the code below does not display any images...what am I missing?
CSS:
#social {
margin: 0;
padding: 0;
height: 15px;
}
#social li {
margin: 0 5px 0 0;
padding: 0;
list-style-type: none;
display: inline;
height: 15px;
float: left;
}
#social li.last{
margin-right:0px;
}
#social li a {
background-image: url("../images/icon_twitter.png") 0px 0px;
background-repeat: no-repeat;
display: block;
height: 15px;
width: 18px;
}
#social li#social-twitter a{
background-position: 0px 0px;
}
#social li#social-twitter a:hover {
background-position: 0px -15px;
}
#social li#social-youtube a{
background-position: -18 top;
}
#social li#social-youtube a:hover {
background-position: -18 -15px;
}
#social span {
display: none;
}
HTML:
<ul id="social">
<li id="social-twitter"><span>Twitter</span></li>
<li id="social-youtube" class="last"><span>Youtube</span></li>
</ul>
You are trying to set the background position within background-image.
Change this:
background-image: url("../images/icon_twitter.png") 0px 0px;
To this:
background-image: url("../images/icon_twitter.png");
background-position: 0px 0px;
Problem: You are using background-position with background-image property
Solution: Either use only background property or use background-position separately
background: color url(src) repeat position;
or
background-image: url(src);
background-position: position;
Your code should like this:
background: url("../images/icon_twitter.png") 0 0 no-repeat;
Note: You should use px (or any other unit) with non zero numbers and zero should be used without unit.
My drop down menu is having some issues with the images not appearing straight away. I have added in a preloader for all the images as I thought that maybe the issue but they still flicker. The drop down menu is under 'apartments'. My preloader code is a javascript that i am using and have now added that in my code.
<style>
#container {
width: 950px;
margin: 0px auto;
top: 0px;
background-color:#000000;
}
#nav {
width: 950px;
margin: 0px auto;
z-index:100;
}
#nav ul {
list-style-type: none;
}
#nav ul li {
float: left;
position: relative;
}
#nav ul li a {
padding:0px 0px 0px 0px;
display:block;
border-bottom: none;
}
#nav ul li ul {
display: none
}
#nav ul li:hover ul {
display: block;
position: absolute;
text-decoration:none;
border-bottom: none;
}
#nav ul li:hover ul li a {
display:block;
padding:0px;
width: 139px;
background:#000;
color:#fff;
}
#nav ul li:hover ul li a:hover {
border-bottom: 1px solid #FFE300;
}
#nav li.list1 {
background-image: url(images/main_nav/image.jpg); background-repeat: no-repeat; border:none; background-position: 0px 0px; width: 127px; height: 30px;
}
#nav li.list2 {
background-image: url(images/main_nav/image_over.jpg); background-repeat: no-repeat; border:none; background-position: 0px 0px; width: 139px; height: 30px; }
#nav li.list3 {
background-image: url(images/main_nav/image_over.jpg); background-repeat: no-repeat; border:none; background-position: 0px 0px; width: 177px; height: 30px; }
#nav li.list4 {
background-image: url(images/main_nav/image_over.jpg); background-repeat: no-repeat; border:none; background-position: 0px 0px; width: 195px; height: 30px; }
#nav li.list5 {
background-image: url(images/main_nav/image.jpg); background-repeat: no-repeat; border:none; background-position: 0px 0px; width: 128px; height: 30px; }
#nav li.list6 {
background-image: url(images/main_nav/image.jpg); background-repeat: no-repeat; border:none; background-position: 0px 0px; width: 134px; height: 30px; }
#nav a#item1 {
background-image: url(images/main_nav/image.jpg); background-repeat: no-repeat; border:none; background-position: 0px 0px; width: 127px; height: 30px; }
#nav a#item2 {
background-image: url(images/main_nav/image.jpg); background-repeat: no-repeat; border:none; background-position: 0px 0px; width: 139px; height: 30px; }
#nav a#item3 {
background-image: url(images/main_nav/image.jpg); background-repeat: no-repeat; border:none; background-position: 0px 0px; width: 177px; height: 30px; }
#nav a#item4 {
background-image: url(images/main_nav/image.jpg); background-repeat: no-repeat; border:none; background-position: 0px 0px; width: 195px; height: 30px; }
#nav a#item5 {
background-image: url(images/main_nav/image.jpg); background-repeat: no-repeat; border:none; background-position: 0px 0px; width: 128px; height: 30px; }
#nav a#item6 {
background-image: url(images/main_nav/image.jpg); background-repeat: no-repeat; border:none; background-position: 0px 0px; width: 134px; height: 30px; }
#nav a#item7 {background-image: url(images/main_nav/image.jpg); background-repeat: no-repeat; border:none; background-position: 0px 0px; width: 134px; height: 30px; }
#nav a#item8 {background-image: url(images/main_nav/image.jpg); background-repeat: no-repeat; border:none; background-position: 0px 0px; width: 134px; height: 30px; }
#nav a#item1:hover {
background-image: url(images/main_nav/image_over.jpg); background-repeat: no-repeat; border:none; background-position: 0px 0px; width: 127px; height: 30px; text-decoration:none; }
#nav a#item2:hover {
background-image: url(images/main_nav/image_over.jpg); background-repeat: no-repeat; border:none; background-position: 0px 0px; width: 139px; height: 30px; text-decoration:none;}
#nav a#item3:hover {
background-image: url(images/main_nav/image_over.jpg); background-repeat: no-repeat; border:none; background-position: 0px 0px; width: 177px; height: 30px;text-decoration:none; }
#nav a#item4:hover {
background-image: url(images/main_nav/image_over.jpg); background-repeat: no-repeat; border:none; background-position: 0px 0px; width: 195px; height: 30px;text-decoration:none; }
#nav a#item5:hover {
background-image: url(images/main_nav/image_over.jpg); background-repeat: no-repeat; border:none; background-position: 0px 0px; width: 128px; height: 30px; text-decoration:none;}
#nav a#item6:hover {
background-image: url(images/main_nav/image_over.jpg); background-repeat: no-repeat; border:none; background-position: 0px 0px; width: 134px; height: 30px; text-decoration:none;}
#nav a#item7:hover {background-image: url(images/main_nav/image_over.jpg); background-repeat: no-repeat; border:none; background-position: 0px 0px; width: 134px; height: 30px; }
#nav a#item8:hover {background-image: url(images/main_nav/image_over.jpg); background-repeat: no-repeat; border:none; background-position: 0px 0px; width: 134px; height: 30px; }
.current1 {
background-image: url(images/main_nav/image_over.jpg); background-repeat: no-repeat; border:none; background-position: 0px 0px; width: 127px; height: 30px;}
.current2 {
background-image: url(images/main_nav/image_over.jpg); background-repeat: no-repeat; border:none; background-position: 0px 0px; width: 139px; height: 30px; }
.current3 {
background-image: url(images/main_nav/image_over.jpg); background-repeat: no-repeat; border:none; background-position: 0px 0px; width: 177px; height: 30px; }
.current4 {
background-image: url(images/main_nav/image_over.jpg); background-repeat: no-repeat; border:none; background-position: 0px 0px; width: 195px; height: 30px; }
.current5 {
background-image: url(images/main_nav/image_over.jpg); background-repeat: no-repeat; border:none; background-position: 0px 0px; width: 128px; height: 30px; }
.current6 {
background-image: url(images/main_nav/image_over.jpg); background-repeat: no-repeat; border:none; background-position: 0px 0px; width: 134px; height: 30px; }
.current7 {background-image: url(images/main_nav/image_over.jpg); background-repeat: no-repeat; border:none; background-position: 0px 0px; width: 134px; height: 30px; }
.current8 {background-image: url(images/main_nav/image_over.jpg); background-repeat: no-repeat; border:none; background-position: 0px 0px; width: 134px; height: 30px; }
.none {display:none;}
</style>
<body>
<div id="container">
<div id="nav">
<ul>
<li class="current1"><span class="none">STORY</span></li>
<li class="list2"><span class="none">APARTMENTS</span>
<ul>
<li class="list7"><span class="none">GALLERY</span></li>
<li class="list8"><span class="none">FLOORPLANS</span></li>
</ul>
</li>
<li class="list3"><span class="none">MEET THE LOCALS</span></li>
<li class="list4"><span class="none">MEET THE CREATORS</span></li>
<li class="list5"><span class="none">LOCATION</span></li>
<li class="list6"><span class="none">CONTACT</span></li>
</ul>
</div><!--end nav-->
</div>
</body>
javascript preloader
var images = new Array()
function preload() {
for (i = 0; i < preload.arguments.length; i++) {
images[i] = new Image()
images[i].src = preload.arguments[i]
}
}
preload(
"images/main_nav/Apartments_over.jpg",
"images/main_nav/Apartments.jpg",
"images/main_nav/Contact_over.jpg",
"images/main_nav/Contact.jpg",
"images/main_nav/Floorplans_over.jpg",
"images/main_nav/Floorplans.jpg",
"images/main_nav/Gallery_over.jpg",
"images/main_nav/Gallery.jpg",
"images/main_nav/MeetTheCreators_over.jpg",
"images/main_nav/MeetTheCreators.jpg",
"images/main_nav/MeetTheLocals_over.jpg",
"images/main_nav/MeetTheLocals.jpg",
"images/main_nav/Story_over.jpg",
"images/main_nav/Story.jpg"
)
You need to execute the preloader function in the body onload
Try changing this
<body>
To this
<body onload="javascript:preload">
You can combine the menu images in a single sprite, for example with this tool. You just have to replace the rule names in the resulting css and set the background image in a more generalized rule.
.nivo-controlNav does center itself inside the slider, but i can't get to center .nivo-controlNav span inside .nivo-controlNav.
code inspector:
.nivo-controlNav {
margin: 0 auto;
text-align: center;
width: 200px;
}
.nivo-controlNav span {
text-align: center;
}
.nivo-controlNav a {
display: block;
float: left;
width: 22px;
height: 22px;
background: url(images/bullets.png) no-repeat;
text-indent: -9999px;
border: 0;
margin-right: 3px;
margin: 0 auto;
}
.nivo-controlNav a.active {
background-position: 0 -22px;
}
.nivo-directionNav a {
display: block;
width: 30px;
height: 30px;
background: url(images/arrows.png) no-repeat;
text-indent: -9999px;
border: 0;
}
a.nivo-nextNav {
background-position: -30px 0;
right: 15px;
}
a.nivo-prevNav {
left: 15px;
}
.nivo-caption {
text-shadow:none;
font-family: Helvetica, Arial, sans-serif;
}
.nivo-caption a {
color:#efe9d1;
text-decoration:underline;
}
.shadow-top {
height: 10px;
background: -webkit-gradient(linear, 0 0, 0 bottom, from(#111), to(#333));
background: -moz-linear-gradient(#111, #333);
-pie-background: linear-gradient(#111, #333);
}
.shadow-bottom {
height: 10px;
background: -webkit-gradient(linear, 0 0, 0 bottom, from(#333), to(#111));
background: -moz-linear-gradient(#333, #111);
-pie-background: linear-gradient(#333, #111);
}
.shadow-slider {
margin: 0 auto;
overflow: hidden;
width: 940px;
height: 10px;
background: -webkit-gradient(linear, 0 0, 0 bottom, from(#999), to(#FFF));
background: -moz-linear-gradient(#999, #DDD);
-pie-background: linear-gradient(#222, #000);
}
#slider img {
float: left;
width: 958px;
height: 458px;
}
EDIT:
(I managed to center the div, but now .nivo-controlNav a loses its width and height because is not floating left).
How to solve this?
#slider-wrapper {
float: left;
height: 500px;
}
#slider {
float: left;
border: 1px solid #DDD;
position:relative;
background:url(images/loading.gif) no-repeat 50% 50%;
}
#slider img {
position:absolute;
top: 0px;
left: 0px;
display: none;
}
.nivo-controlNav {
margin: 480px auto 0;
overflow: hidden;
text-align: center;
width: 200px;
}
.nivo-controlNav span {
}
.nivo-controlNav a {
width: 22px;
height: 22px;
background: url(images/bullets.png) no-repeat;
text-indent: -9999px;
border: 0;
margin-right: 3px;
}
.nivo-controlNav a.active {
background-position: 0 -22px;
}
.nivo-directionNav a {
display: block;
width: 30px;
height: 30px;
background: url(images/arrows.png) no-repeat;
text-indent: -9999px;
border: 0;
}
a.nivo-nextNav {
background-position: -30px 0;
right: 15px;
}
a.nivo-prevNav {
left: 15px;
}
.nivo-caption {
text-shadow:none;
font-family: Helvetica, Arial, sans-serif;
}
.nivo-caption a {
color:#efe9d1;
text-decoration:underline;
}
I think you can achieve that by just using:
.nivo-controlNav span {
display: inline-block;
}
I would also remove the float:left from the link as that can cause problems. You do need display:block on the link in order to be able to give it a width.
You have a CSS class for .nivo-controlNav a set to float: left; which is likely overriding your text-align: center on the class .nivo-controlNav span
EDIT: To accomplish what you're after, try replacing your span elements with one parent ul and an li element where you have the spans now. Then add the following to your CSS and continue using float: left on your a elements.
.nivo-controlNav li {
text-align: center;
list-style: none;
}
Let me know if this isn't clear and I'll try to setup an example.