css: z-index and float-right - css

I'm trying to lay my menu div onto facebook share div. The main problem is,that z-index doesn't work,even when i use position:relative on both div. Do You know,how i may to fix it?
P.S I added photo where You can see,what exactly goes wrong
http://img4.imageshack.us/img4/1563/problemscreenshot.png
<div id="facebook_connect">
<a href="something,something,something-thedarkside">
<img src="/img/facebook_connect.png"/>
</a>
</div>
<div id="header_menu">
<ul>
<li class="menu_link_left highlight">Strona główna</li>
<li class="menu_link_inside">O nas</li>
<li class="menu_link_inside">Usługi</li>
<li class="menu_link_right">Kontakt</li>
</ul>
</div>
and CSS code:
#facebook_connect{
height:50px;
width:20px;
top:30px;
position:relative;
z-index:1;
float:right;
}
#facebook_connect a, img{
position:relative;
z-index:1;
}
/*=======================================*/
#header_menu{
position:relative;
z-index:2;
height:30px;
width:350px;
background:#ececec;
border-radius:5px;
float:right;
top:60px;
-moz-box-shadow: 0px 0px 6px #000;
-webkit-box-shadow: 0px 0px 6px #000;
box-shadow: 0px 0px 6px #000;
}

So, if I'm not mistaken, what you're trying to accomplish is having your Facebook share button underneath your navigation, and I'm assuming you want it to protrude a bit from the top, giving it a somewhat layered effect.
If this is the case, the issue is not with the z-index, it is a positioning issue. You can correct this by placing the two divs within a container. Try this:
HTML:
<div id="cont">
<div id="header_menu">
<ul>
<li class="menu_link_left highlight">Strona główna</li>
<li class="menu_link_inside">O nas</li>
<li class="menu_link_inside">Usługi</li>
<li class="menu_link_right">Kontakt</li>
</ul>
</div>
<div id="facebook_connect">
<a href="something,something,something-thedarkside">
<img src="/img/facebook_connect.png"/>
</a>
</div>
</div>
CSS:
#cont {
position: relative;
top:60px;
float:right;
}
#facebook_connect{
position:absolute;
top: 5px;
right: 20px;
height:50px;
width:20px;
z-index:1;
}
#header_menu{
position: relative;
height:30px;
width:350px;
background:#ececec;
border-radius:5px;
-moz-box-shadow: 0px 0px 6px #000;
-webkit-box-shadow: 0px 0px 6px #000;
box-shadow: 0px 0px 6px #000;
z-index:2;
}
Then position as you see fit.

Related

Why do the elements below also move to the right with this css?

The code below displays some text (#_EVENTEXCERPT) and displays a picture (#_EVENTIMAGE). I want it so the text is on the left and the image on the right, so they are next to each other, as this code does. Below this there is a <a href="#_EVENTURL with lots of css which makes this link into an orange button. Currently, this orange button is being moved right with the image. I don't want this to happen, how can I move the image next to the text (as is currently), but leave the <a href to the left?
from style sheet:
#eventexcandimage {
width: 100%;
}
from .php file:
<div id="eventexcandimage">
<span style="width: 50%; float: left; "> #_EVENTEXCERPT </span>
#_EVENTIMAGE </div>
</li>
<li>
<span style="width:50%; " > <a href="#_EVENTURL" style=" -moz-box-shadow:inset 0px 1px 0px 0px #ed834e;
-webkit-box-shadow:inset 0px 1px 0px 0px #ed834e;
box-shadow:inset 0px 1px 0px 0px #ed834e;
background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #ed834e), color-stop(1, #ed834e) );
background:-moz-linear-gradient( center top, #ed834e 5%, #ed834e 100% );
background-color:#ed834e;
-webkit-border-top-left-radius:0px;
-moz-border-radius-topleft:0px;
border-top-left-radius:0px;
-webkit-border-top-right-radius:0px;
-moz-border-radius-topright:0px;
border-top-right-radius:0px;
-webkit-border-bottom-right-radius:0px;
-moz-border-radius-bottomright:0px;
border-bottom-right-radius:0px;
-webkit-border-bottom-left-radius:0px;
-moz-border-radius-bottomleft:0px;
border-bottom-left-radius:0px;
text-indent:0px;
display:inline-block;
color:#fffffb;
font-family:Arial;
font-size:13px;
font-weight:bold;
font-style:normal;
height:35px;
line-height:35px;
width:111px;
text-decoration:none;
text-align:center;
text-shadow:1px 1px 0px #ed834e;
"> More Info / Book</a> </span>
Thank-you!
UPDATE: YI want the button to be on a new line below the text/image. It is currently above the image on the right, I don't know why.
Okay so I took your code and hopefully made it work the way you wanted it to(?)..Maybe.
Also just below your code I rewrote it not using span or li but rather div's as they're better for positioning than the former two. Here is link to the Fiddle as well it attached as a snippet.
.btn {
-moz-box-shadow:inset 0px 1px 0px 0px #ed834e;
-webkit-box-shadow:inset 0px 1px 0px 0px #ed834e;
box-shadow:inset 0px 1px 0px 0px #ed834e;
background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #ed834e), color-stop(1, #ed834e) );
background:-moz-linear-gradient( center top, #ed834e 5%, #ed834e 100% );
background-color:#ed834e;
-webkit-border-top-left-radius:0px;
-moz-border-radius-topleft:0px;
border-top-left-radius:0px;
-webkit-border-top-right-radius:0px;
-moz-border-radius-topright:0px;
border-top-right-radius:0px;
-webkit-border-bottom-right-radius:0px;
-moz-border-radius-bottomright:0px;
border-bottom-right-radius:0px;
-webkit-border-bottom-left-radius:0px;
-moz-border-radius-bottomleft:0px;
border-bottom-left-radius:0px;
text-indent:0px;
display:inline-block;
color:#fffffb;
font-family:Arial;
font-size:13px;
font-weight:bold;
font-style:normal;
height:35px;
line-height:35px;
width:111px;
text-decoration:none;
text-align:center;
text-shadow:1px 1px 0px #ed834e;
}
.event {
width: 100%;
margin-top: 25px;
}
.event_info {
width: 100%;
margin-bottom: 5px;
}
.event-text {
float: left;
width: 50%;
}
.event-text > h3 {
margin: 0;
padding: 0;
}
.event-img {
width: 50%;
float: left;
}
.img {
width: 100%;
height: 125px;
background: red;
display: block;
}
<ul>
<li>
<div id="eventexcandimage">
<span style="width: 50%; float: left; ">
#_EVENTEXCERPT
</span>
<div style="width: 50%; float: left;">
<img class="img" src="" />
</div>
</div>
</li>
<li style="clear: both;"> <span style="width:50%; "> More Info / Book </span>
</li>
</ul>
<div class="event">
<div class="event-info">
<div class="event-text">
<h3>Event Title</h3>
<p>Text about your event</p>
</div>
<div class="event-img">
<img class="img" src="" />
</div>
</div> <!-- End event-info -->
<div style="clear: both;">
More Info / Book
</div>
</div>
I'm going to assume that your provided HTML has been cut off because some of your tags are not properly opened nor closed, but that's irrelevant as to why you're seeing the behavior you are.
span by default is displayed inline (everything naturally flowing on a line). You have your button in a span which means it's trying to stay on the same line as the things before it, which is doing what you're seeing. So what can you do? Well, the quickest fix is to make this button start on a new line. Change the display on the button to display:block. Block level elements take up the entire width, which will force a line break since something that is full width can't share the line with other things.

Right border shifts to bottom line

http://jsfiddle.net/W9LXd/
I want the div under the #araclar to have it's right border stay in the same line. How can I prevent it from shifting?
CSS:
#düzenleyici{
border: 1px solid #000;
width: 600px;
height: 300px;
box-shadow: 1px 1px 4px #000;
}
#araclar{
width:auto;
height:50px;
background:#EEEEEE;
display:block;
padding:5px 15px 5px 15px;
border-bottom:1px solid #000;
}
#araclar>div{
padding:0 5px 0 5px;
display:inline;
border:1px solid #000;
}
HTML:
<div id="düzenleyici">
<div id="araclar">
<div>
Renk
<div>
</div>
</div>
Change display: inline; to display: inline-block;
Use: http://jsfiddle.net/W9LXd/1/
display: inline-block instead of display-inline
Or give a specific width.
IMO there is no problem with your CSS
Your HTML is malformed, Please close the inner most div - on which you have set display:inline
<div id="düzenleyici">
<div id="araclar">
<div>
Renk
</div> <!-- yOU have not closed the tag here -->
</div>
</div>
FIDDLE

<a> tag is not working properly

I have an <a> element which is being recognized by the browser because the pointer changes when I put it over the element, and in the down-left corner of the browser appears the URL, but when I click it the browser does not navigate.
Here is the HTML code:
<div class="service-box style2">
<div class="iconbox-style2">
<div class="inner">
<i class="fa fa-circle-o"></i>
</div>
</div>
<h4>Loren</h4>
<p>Loren ipsum .-......</p>
Info
</div>
And the CSS:
.service-box.style2{border:1px solid #f2f2f2;
padding:20px 10px;
margin-top:30px;
-webkit-box-shadow:0px 2px 0px rgba(252,252,252,1);
-moz-box-shadow:0px 2px 0px rgba(252,252,252,1);
box-shadow:0px 2px 0px rgba(252,252,252,1);
}
.service-box.style2 .iconbox-style2{
width:60px;
height:60px;
text-align:center;
padding-top:20px;
font-size:48px;
margin:-60px auto 20px;
background:#fff;
color:#44BFE8; }
.inner{
padding:20px;
background:#44BFE8;
border:1px solid rgba(0,0,0,0.05);}
Any idea? Thank you so much in advance!
What I feel is, the class gray is used for giving disabled state for the buttons. Try using this code instead:
Info

css dialox box to html li item

how can I have kinda like dialog boxes besite the bullet of a li element?
<div class="contentContenedor">
<div class="tituloContentContenedor">Box: Promociones nacionales</div>
<div class="linksContentContenedor">
<ul>
<li>
<span>Vuela barato por Chile</span>
<span class="linksContentContenedorClicks" style="background-color:blue; color:white; float:right; padding:0px 4px 0px 4px">612</span>
</li>
<li>
<span>Encántate con el sur de nuestro país</span>
<span class="linksContentContenedorClicks" style="background-color:blue; color:white; float:right; padding:0px 4px 0px 4px">102</span>
</li>
<li>
<span>Disfruta el norte de Chile</span>
<span class="linksContentContenedorClicks" style="background-color:blue; color:white; float:right; padding:0px 4px 0px 4px">64</span>
</li>
<li>
<span>Canjea tus kms. y vuela por Chile</span>
<span class="linksContentContenedorClicks" style="background-color:blue; color:white; float:right; padding:0px 4px 0px 4px">49</span>
</li>
</ul>
</div>
</div>
(I can change de order of the span, or put the info outside the li)
CSS:
.contentContenedor{
background-image:url('img/fondo_cajas_home.gif');
background-repeat:no-repeat;
background-position:center bottom;
width:270px;
height:140px;
}
.tituloContentContenedor{
background-image:url('img/fondo_tit_cajas_home_270_23.gif');
background-repeat:no-repeat;
width:270px;
height:23px;
color:white;
font:bold 11px Arial,Helvetica,sans-serif;
padding:6px 0px 2px 11px;
}
.linksContentContenedor{
font-size:12px;
text-decoration:underline;
color:#0267C3;
}
.linksContentContenedor ul{
padding:0;
margin:0;
margin-left:28px;
padding-bottom:10px;
}
.linksContentContenedor li span{
position:relative;
left:-5px;
}
.linksContentContenedorClicks{
position:absolute;
left:10px;
}
I'm able tu add a square with info beside de li element but it stays inside de container.
I'd like it to be like:
but for each li element and always pointing to the bullet.
what complicates me the most is that im not able to get the info outside the container.
if I add absolute position then I wouldnt know the left and top margins since, this boxes are php created.
PS: it is not a tooltip, kinda looks like it but it has to be always present, not when hovering or whatever.
thsnk youuu!
Here is what I did,
.info {
position: absolute;
right: 115%;
width: 60px;
height: 40px;
background: #c1c1c1;
text-align: center;
}
.info:before {
content: "";
height: 0;
width: 0;
position: absolute;
left: 100%;
border-left: 15px solid #c1c1c1;
border-top: 20px solid transparent;
border-bottom: 20px solid transparent;
}
This css will make the "info box" you are looking for. This is just a start so you can tweek it in anyway you want. If you are looking for just a border and not solid color then I would advice you to use an image. It could be possible I believe but not very effect/supported.
Here is the JSFIDDLE with the rest of css. Just make sure the li containing the .info is position: realtive;.

css border problem

How do i put a border on a div in css that doesn't have a set height?
Want to achieve this without using any javascript. Code is below.
HTML
<div id="main_container">
<div id="header">
<div id="topMenu">
<ul id="topNav">
<li>Home</li><li>Contact</li><li>Links</li>
</ul>
</div>
<div id="mainMenu">
<ul id="mainNav">
<li >Home</li><li >About Us</li><li >Multimedia</li><li >Multimedia</li><li >Multimedia</li><li >Multimedia</li><li >Multimedia</li><li >Multimedia</li>
</ul>
</div>
</div>
</div>
css
body{
text-align:center;
min-width:70%;
}
#main_container{
position:relative;
width:980px;
margin:auto;
text-align:center;
background-color:#FFFFFF;
border-color: #999999;
border-style: solid ;
border-width: 1px ;
margin-bottom: 20px;
}
#header{
position: relative;
width: 980px;
}
#mainMenu{
float:left;
width: 980px;
top: 50px;
background-color: #0099FF;
height: 30px;
}
#mainNav{
text-align: left;
}
ul#mainNav li{
display: inline;
margin: 0px 20px 0px 0px;
}
#topMenu{
width: 150px;
top: 10px;
text-align: right;
float:right;
margin-bottom: 20px;
}
ul#topNav li{
display: inline;
margin: 0px 10px 0px 0px;
}
#footer{}
Thanks in advance.
Does it work?
<div style="border:1px solid #000">
Your content here
</div>
It doesn't matter if there is no height attribute. Just use the border property as you normally would.
Edit: since you mention you have other divs inside your container div, I suspect you might need to use a clear. If you're still having issues with either the background or border not extending the length of the container, try adding this right before the closing div of the container:
<div style="clear:both"></div>
Just give the div some padding or content inside.
div {
border: solid 1px #000;
padding: 10px;
}

Resources