how to force a div to expand to its content? - css

although my questions has been answered lots of times before, but all the proposed solution I have tried and nothing seems to work.
what am trying to do is a big div that contains li tags; the li tags will also contain anchor tag, 2 divs and p tag.
to understand the big picture.. am trying to make a posting wall (activity-board), the wall will have posts looks like a bubble (div post) and the bubble will point (post-arrow) to a thumbnail image (a thumb3), to make the bubble style I made the post div absolute positioned with z-index less than the arrow-post.
and here is my css:
.activity-board {
background:#fff;
width:600px;
min-height:652px;
height:auto;
border:solid 2px #e7d28d;
border-radius: 6px;
-moz-border-radius: 6px;
-webkit-border-radius: 6px;
-webkit-box-shadow: inset 0px 0px 0px 3px rgba(255, 255, 255, 1);
box-shadow: inset 0px 0px 0px 3px rgba(255, 255, 255, 1);
float:left;
margin-left:20px;
}
.post-body{
position:relative;
display:block;
list-style-type:none;
width:600px;
height:auto;
background:#f9f9f9;
border-bottom:1px solid #CBCBCB;
border-radius:4px 4px 0 0;
-moz-border-radius:4px 4px 0 0;
-webkit-border-radius:4px 4px 0 0;
background: #fff;
float:left;
overflow:visible;
clear:both;
z-index:9;
}
.post{
position:absolute;
width:500px;
line-height:20px;
height:auto;
background:#FFF;
display:block;
margin-top:22.5px;
margin-left:77px;
text-align:left;
float:left;
z-index:1;
}
.post-arrow{
position:relative;
margin-top:32px;
margin-left:6px;
width:12px;
height:18px;
background:url(images/post-arrow.png);
float:left;
z-index:5;
}
.post p{ color:#025373; padding:8px; word-wrap:break-word; }
a.thumb-3 {
margin-top:18px;
display:block;
margin-left:18px;
width:46px;
height:46px;
border-radius: 5px;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
z-index:10;
float:left;
}
a.thumb-3 img{
padding:0;
margin:0 auto;
width:46px;
height:46px;
float:left;
border-radius:3px;
-moz-border-radius:3px;
-webkit-border-radius:3px;
}
here is my html:
<ul>
<li class="post-body">
<a class="thumb-3"><img src="images/Alsheikh Center (177).jpg" /></a>
<div class="post-arrow"></div>
<div class="post">
<p>
Hi there!
</p>
</div>
</li>
</ul>
http://jsfiddle.net/r9YpX/
Everything worked fine but the li tag does not expand to the content.. it only expands if I change the position of the post div to relative not absolute, which I cant change because it must be absolutely positioned under the arrow image to give it the bubble look.
any help would be appreciated.
Thanks.

ok Thanks guys i figuered it out.. I made position:relative and changed margin for post div and it worked! I thought I did this but perhaps I did something wrong that make it not work

Related

Nested divs Background-color

I am trying to change background-color of the parent div behind the children ones. Kind of like how the how the background in this image is darker than the other divs.
here is my HTML:
<div class="main">
<div class="sub">
</div>
</div>
CSS:
div.main {
background-color:#AAAAAA;
}
div.sub {
border-style:solid;
border-width:1px;
border-color:#AAAAAA;
border-radius:2px;
margin:10px;
box-shadow: 0px 0px 5px #AAAAAA;
}
The main div is not the color #AAAAAA
Thanks, Ben
You forgot to add background-color in sub class and also add padding for the clear view.
div.main {
background-color:#AAAAAA;
padding:20px;
}
div.sub {
border-style:solid;
border-width:1px;
border-color:#AAAAAA;
border-radius:2px;
margin:10px;
box-shadow: 0px 0px 5px #AAAAAA;
padding:10px;
background-color:#fff;
}
I tried doing the same thing, it may help: JSFiddle
just assign a different background color to your different divs, maybe add some padding to make it show?
div.main {
background-color:#888888; //<---------- darker
padding: 10px; //<-------- padding
}
div.sub {
border-style:solid;
background-color:#AAAAAA; //<---------- lighter
border-width:1px;
border-color:#AAAAAA;
border-radius:2px;
margin:10px;
box-shadow: 0px 0px 5px #AAAAAA;
}

CSS Issue with Chrome - Navigation element bump

Working on an academic mock-up for a class. It's a simple reproduction of an existing company's webpage using only HTML and CSS. Everything was working perfectly in all browsers last week. I opened it yesterday to check it before submission and there's a problem.
In Chrome only, the last element of my navbar is being bumped straight down 19px.
The page. link
The css. link
The relevant css.
#navbar {
position:absolute;
display:block;
top: 115px;
left:0px;
width:100%;
height: 45px;
background:url(../images/navbar_section.png) repeat-x;
padding:0px;
margin:0 auto;
text-align:center;
-webkit-box-shadow: 0px 2px 2px rgba(50, 50, 50, 0.27);
-moz-box-shadow: 0px 2px 2px rgba(50, 50, 50, 0.27);
box-shadow: 0px 2px 2px rgba(50, 50, 50, 0.27);
}
#navmenu {
float:left;
left:50%;
position:relative;
width:964px;
}
#navmenu ul, li {
display: inline;
}
#navmenu li a {
font-size:1em;
float: left;
color: white;
font-weight:bold;
border-left:2px groove #008dcb;
text-decoration: none;
line-height:45px;
position:relative;
margin-left:auto;
margin-right:auto;
right:50%;
padding-left:10px;
padding-right:10px;
width:138px;
}
#navmenu li a:hover {
color: white;
background:url(../images/navbar_visited.png);
}
#navmenu li:last-child a {
border-right:2px groove #008dcb;
}
The relevant html.
<div id="navbar">
<div id="navmenu">
<ul>
<li>SHOP</li>
<li>WHY ALLTEL</li>
<li>PLANS</li>
<li>APPS & MORE</li>
<li>CAREERS</li>
<li>EMPLOYEES</li>
</ul>
</div><!--end of navmenu-->
</div><!--end of navbar-->
I know it may be a bit confusing, if you look at the css file, to see navmenu and navmenu2, but just focus on navmenu, as the second is a different style that I haven't implemented.
I've tried removing the width elements with no change in the error.
I've tried copying the above code only into a fresh html document. Same error.
I'm at a complete loss. Please help!
Clear padding. This is post just so there's a listed, recognized solution to this question.

Text overlapping with drop-down

I have CSS code from a template design that a client wants to use. One of the issue I'm having is that, once a text option is selected (those options with wide length) is writing over the drop-down arrow.
See image
I have tried using z-index and placing overflow:hidden where appropriate. Here is the CSS code:
/* search drop-down values */
select option {}
option.level-0{padding:0 3px;}
option.level-1,option.level-2,option.level-3,
option.level-4,option.level-5,option.level-6,
option.level-7{}
.selectBox-dropdown{ height: 34px; min-width:190px; max-width: 320px; position:relative; border:solid 1px #BBB; line-height:1; text-decoration:none; color:#666; outline:none; vertical-align:middle; background:#FFF; -webkit-border-radius:6px; -moz-border-radius:6px; border-radius:6px; display:inline-block; cursor:default; margin-top: 1px\9; height: 33px\9;}
.content_right .selectBox-dropdown {width:303px;}
.content_right a.selectBox-dropdown:hover {text-decoration:none;}
.selectBox-dropdown:focus,
.selectBox-dropdown:focus .selectBox-arrow{border-color:#BBB}
.selectBox-dropdown.selectBox-menuShowing{-moz-border-radius-bottomleft:0; -moz- border-radius-bottomright:0; -webkit-border-bottom-left-radius:0; -webkit-border-bottom-right-radius:0; border-bottom-left-radius:0; border-bottom-right-radius:0}
.selectBox-dropdown .selectBox-label{width:100%; padding:0 .7em; line-height:2.4em; display:inline-block; white-space:nowrap; overflow:hidden; font-size:14px}
.selectBox-dropdown .selectBox-arrow{position:absolute; top:0; right:0; width:23px; height:100%; background:url(images/sb-arrow.png) 50% center no-repeat; border-left:solid 1px #BBB; }
.selectBox-dropdown-menu{position:absolute; z-index:99999; max-height:200px; border:solid 1px #BBB; background:#FFF; -moz-box-shadow:0 2px 6px rgba(0,0,0,.2); -webkit-box-shadow:0 2px 6px rgba(0,0,0,.2); box-shadow:0 2px 6px rgba(0,0,0,.2); overflow:auto}
.selectBox-inline{width:250px; outline:none; border:solid 1px #BBB; background:#FFF; display:inline-block; -webkit-border-radius:4px; -moz-border-radius:4px; border-radius:4px; overflow:hidden;}
.selectBox-inline:focus{border-color:#666}
.selectBox-options,
.selectBox-options li,
.selectBox-options li a{list-style:none; display:block; cursor:default; padding:0; margin:0}
.selectBox-options li a{color:#666; padding:1px .7em; white-space:nowrap; overflow:hidden; background:6px center no-repeat; text-decoration:none; font:14px/1.5em Arial,Helvetica,sans-serif;}
.selectBox-options li.selectBox-hover a{background-color:#EEE}
.selectBox-options li.selectBox-disabled a{color:#888; background-color:transparent}
.selectBox-options .selectBox-optgroup{color:#666; background:#EEE; font-weight:bold; line-height:1.5; padding:0 .3em; white-space:nowrap;}
.selectBox.selectBox-disabled{color:#888 !important}
.selectBox-dropdown.selectBox-disabled .selectBox-arrow{opacity:.5; filter:alpha(opacity=50); border-color:#666;}
.selectBox-inline.selectBox-disabled{color:#888 !important}
.selectBox-inline.selectBox-disabled .selectBox-options a{background-color:transparent !important}
code for the drop-down:
<div class="state-dropdown"><?php wp_state_dropdown() ?></div>
<span id="campus_dropdown"><?php if (empty($_GET['cp_state'])){ wp_campus_dropdown();} ?></span>
<?php if (!empty($_GET['cp_state'])){?>
<script type="text/javascript" >loadXMLDoc('<?php echo $_GET['cp_state'];?>','<?php echo $_GET['cp_your_college'];?>')</script>
<?php }?>
Any suggestions or help would be greatly appreciated. I know this is a bit too much of CSS, but again its from a template and I have been pulling my hair out for weeks!
Thank you so much in advance!
First of all without sample HTML, we can only guess at how the css is used. After analyzing the css you provided, I took a stab at how I thought it might be used, jsFiddle here. Based on this assumption there are two options:
Set a right padding for the elements that contain the menu options. This may cause the dropdown to widen, but should be better as it will allow users to see the entire text of the option.
Set the background for the dropdown arrow element ('.selectBox-arrow') to a solid color and match the border radius of the containing element. Note that the background color defaults to transparent.
If for whatever reason neither of these options work in your situation, remember, Firebug (or other browser's developer tools) are your friend. These tools can help make short work of problems like this.

HTML, CSS Header Assistance

Since i won't be able to post an image here's the link to it
http://i.stack.imgur.com/LxO1e.png
I have this website, the PHP and all other stuff are working. The problem is that when I scroll up to see other stuff below, the elements that get scrolled up goes over the header instead of going under. How do I solve this?
I can't seem to post the HTML in here, I tried the indent four spaces thing but it doesn't work with HTML stuff so instead here is the site: pageboost.comze.com
Here's the css for the main that is going over instead of under
.inmain
{
width:95%;
height:100%;
left:20px;
top:42px;
position:relative;
}
and here's the css for the header
.header
{
background-color:#ffd800;
width:100%;
height:42px;
position:fixed;
left:0px;
top:0px;
-webkit-box-shadow: 0 5px 6px -6px black;
-moz-box-shadow: 0 5px 6px -6px black;
}
You have to define z-index with one these positions relative,absolute or fixed.
For example write like his:
.header{
position:fixed;
z-index:1;
}
just define z-index value into your Header class or Id where you have defined the position.
It happens so when you will give the z-index value i hope that will work smoothly.....
UPDATED ANSWER
I have given the z-index value in header class its working fine now please check it.....
HTML
<div class="header"></div>
<div class="inmain">afdadfasf</div>
CSS
.header
{
background-color:#ffd800;
width:100%;
height:42px;
position:fixed;
left:0px;
top:0px;
-webkit-box-shadow: 0 5px 6px -6px black;
-moz-box-shadow: 0 5px 6px -6px black;
z-index:1;
}
.inmain
{
width:95%;
height:100%;
left:20px;
top:35px;
position:relative;
}
for better understanding see the live demo:- http://jsfiddle.net/X8vpg/6/

Why doesn't the title tooltip work for floated elements?

I have a floated element, the whole purpose of which is to display an 'x' signifying that you can remove something:
.remove_button{
background-color:#ff3300;
color:#ffffff;
font-family:Courier New,sans-serif;
font-weight:900;
font-size:20px;
float:right;
border-radius:5px;
padding:0px 6px 0px 6px;
margin-right:15px;
}
<div class="remove_button" title="Remove">x</div>
It does display a neat little 'x' over a red background (no need to make a picture, I'm bad at that), but the problem is that when the mouse hovers over the button the title attribute shows up inside the button, and as a tooltip too:
------xRemove------ one '-' is one pixel of padding
try this,
.remove_button{
background-color:#ff3300;
color:#ffffff;
font-family:Courier New,sans-serif;
font-weight:900;
font-size:20px;
float:right;
border-radius:5px;
padding:0px 6px 0px 6px;
margin-right:15px;
position:relative;
}
​ .tip{
position:absolute;
display:none;
border:1px solid #aab;
background:#eef;
padding:0 3px;
left:15px;
top:25px;
}
.remove_button:hover .tip{
display:block;
}
​​​​​​​​​

Resources