Preventing Div Elements From Wrapping in a Fluid Navigation - css

I have a top nav that extends across the page
Within that top nav I have various elements
two that must align left
one that must align right
The nav is fluid the elements are fixed widths
Do not want the elements to wrap when the browser window is minimized
Needs to work in IE6 on up due to high Chinese audience.
See example here:
http://jsfiddle.net/4SUwg/
<div id="header">
<div id="headerContent">
<div class="search-list"> Search List </div>
<div class="social-buttons"> Social </div>
<div class="signin"> Login Drop Down </div>
</div>
</div>
I would like the div elements within the nav to not wrap. I searched around on stack and could find answers that come close but nothing that completely addressed the issue. My need to have the div element aligned right complicates matters. Must work in all browsers, especially IE's.
Thanks all for your help in advance!!!

Use SPAN .. It's INLINE and not BLOCK ??
<div id="header">
<div id="headerContent">
<span class="search-list"> Search List </span>
<span class="social-buttons"> Social </span>
<span class="signin"> Login Drop Down </span>
</div>
</div>
And your CSS, remove floats
<style>
body {
margin:0;
padding:0;
}
#header {
background: #404040;
height: 35px;
color: white;
margin: 0 0 12px 0;
overflow-x:auto; overflow-y:hidden;
}
#headerContent {
height: 32px;
border:1px dashed #fff;
}
.search-list {
width:150px;
background:#039;
}
.social-buttons {
width:150px;
background:#060;
}
.signin {
width:200px;
background:#F00;
}

You want a fluid layout but the most important rule of a fluid layout is not to set a definite width of elements but you have set the width.
The CSS have a <style> tag, which is not required, probably you put it by mistake.
I have set the width of divs inside headerContent in percentage value. The CSS is
body {
margin:0;
padding:0;
}
#header {
background: #404040;
height: 35px;
color: white;
margin: 0 0 12px 0;
overflow-x:auto; overflow-y:hidden;
}
#headerContent {
height: 32px;
border:1px dashed #fff;
}
.search-list {
width:28%;
float:left;
background:#039;
}
.social-buttons {
width:28%;
float:left;
background:#060;
}
.signin {
width:28%;
float:right;
background:#F00;
}
Just changed the width value and on my browser it looked fine, better than the before version. Here's a fiddle http://jsfiddle.net/DeepakKamat/s52Hn/8/

I found a solution that works in all browsers, specifically IE6 on up since that was a requirement for this project. If you have something better that accomplishes the same thing please post! My sincere thanks to everyone who answered/helped.
<div id="header2">
<table id="headerContent2">
<tr>
<td id="left" valign="top">
<div id="leftWrapper">
<div class="search-list2">Search List</div>
<div class="social-buttons2">Social Buttons</div>
</div>
</td>
<td id="middle"> </td>
<td id="right" valign="top">
<div class="signin2">Login Drop Down</div>
</td>
</tr>
</table>
</div>
<style>
#header2 {
background: #404040;
height: 35px;
color: white;
margin: 0 0 12px 0;
}
#headerContent2 {
width:100%;
}
#headerContent2 td {
height: 32px;
padding:0;
margin:0;
}
.search-list2 {
width:150px;
float:left;
background:#039;
}
.social-buttons2 {
width:200px;
float:left;
background:#060;
}
.signin2 {
background:#F00;
float:right;
width:400px;
}
#leftWrapper {
width:400px;
}
#middle {
width:100%;
}
</style>
See Demo of it working here. Copy the code and try it out in all the IE's since JSfiddle does not work in all IE's.
http://jsfiddle.net/GtXKE/

Related

Designer going to CSS. Fundamental flaws with links in nested centered divs

I want to set up a full width slideshow based on the Design I've prepared. I'm building the page on the Unsemantic CSS framework as I was already familiar with 960 gridsystem (960.gs).
What I'm missing is how to write physically correct HTML & CSS. I don't want to build these unstable workarounded glued pages like most.
I've tried my best to build it but nothing seems to work the way it should. Here is a part of the page where a slideshow should appear.
However, it looks like this.
Here's the CCS:
<style>
.slide-wrapper{
background-color:black;
width:100%;
overflow:hidden;
}
.slide-item{
width:100%;
overflow:hidden;
color:white;
}
.slide-img-wrapper{
position:relative;
}
.slide-img{
width:100%;
float:left;
position:relative;
}
.slide-description{
position:absolute;
float:left;
text-align:center;
width: 100%;
margin-top:16%;
}
.description-wrapper{
}
</style>
<div id="slide-wrapper">
<div class="slide-item">
<img class="slide-img" src="../villas.praivit/img/lead.jpg" />
<div class="slide-description">
<p class="location">SWITZERLAND, CERN</p>
<h1>VILLA PANORAMA</h1>
<p class="details">Local Time <b>4:10 am</b>, Temperature <b>32F°</b></p>
<div class="button-1">VIEW VILLA</div>
</div>
</div>
</div>
Is this what you are looking for?
<div id="slide-wrapper">
<div class="slide-item">
<img class="slide-img" src="http://dreamatico.com/data_images/mountain/mountain-1.jpg" />
<div class="slide-description">
<p class="location">SWITZERLAND, CERN</p>
<h1>VILLA PANORAMA</h1>
<p class="details">Local Time <b>4:10 am</b>, Temperature <b>32F°</b></p>
<div class="button-1">VIEW VILLA</div>
</div>
</div>
</div>
.slide-wrapper{
background-color:black;
width:100%;
overflow:hidden;
}
.slide-item{
width:100%;
overflow:hidden;
color:white;
}
.slide-img-wrapper{
position:relative;
}
.slide-img{
width:100%;
float:left;
position:relative;
}
.slide-description{
position:absolute;
float:left;
text-align:center;
width: 100%;
margin-top:16%;
}
.description-wrapper{
}
.button-1{
display: inline-block;
background-color: #b8955d;
color: #fff;
box-sizing: border-box;
padding: 10px;
}
.button-1 a{
color: #fff;
text-decoration: none;
}

trouble aligning div side by side

I'm trying to get the shoutbox on www.talkjesus.com (vBulletin forum) to float left while the verse of the day (orange) to float on the very right side of the shoutbox. I've tried so many variations but it's not working, I'm stuck. Your help appreciated.
The forumhome template code I'm using now is:
<div class="blockbody formcontrols floatcontainer">
<div id="wgo_onlineusers" class="wgo_subblock">
<h3 class="blocksubhead" style="background-color:#82BA1B; color: #fff !important; font-size: 22px; font-weight: 300">shoutbox</h3>
<div style="text-align: center; line-height: 0" class="blockrow">
<div><iframe frameborder="0" width="100%" height="200" src="http://www.cbox.ws/box/?boxid=439&boxtag=7868&sec=main" marginheight="2" marginwidth="2" scrolling="auto" allowtransparency="yes" name="cboxmain1-439"" id="cboxmain1-439" style="border-bottom: 1px solid #e4e4e4;"></iframe></div>
<div style="position:relative"><iframe frameborder="0" width="350" height="70" src="http://www.cbox.ws/box/?boxid=439&boxtag=7868&sec=form&nme={vb:raw cboxnme}&nmekey={vb:raw cboxkey}&pic={vb:raw cboxav}&lnk={vb:raw cboxav}" marginheight="2" marginwidth="2" scrolling="no" allowtransparency="yes" name="cboxform1-439" id="cboxform1-439"></iframe></div>
</div>
</div>
</div>
<br />
<div class="blockbody formcontrols floatcontainer">
<div id="wgo_onlineusers" class="wgo_subblock">
<h3 class="blocksubhead" style="background-color:#E66B1B; color: #fff !important; font-size: 22px; font-weight: 300">verse of the day</h3>
<div>
<div style="font-size:16px; line-height:28px; padding:10px; color: #797979">
<script type="text/javascript" src="http://www.christnotes.org/syndicate.php?content=dbv&type=js2&tw=auto&tbg=ffffff&bw=0&bc=000000&ta=L&tc=43A6DF&tf=Open Sans&ts=14&ty=B&va=L&vc=43A6DF&vf=Open Sans&vs=12&tt=3&trn=NASB"></script>
</div>
</div>
</div>
</div>
relevant CSS code...
/* Auto-clearing of floats */
.floatcontainer:after,
.formcontrols .blockrow:after,
dl.stats:after {
content:".";
display:block;
height:0;
clear:both;
visibility:hidden;
}
.floatcontainer,
.formcontrols .blockrow,
dl.stats {
display:inline-block;
font-weight:normal;
}
/* IE-Mac hide \*/
* html .floatcontainer,
.formcontrols .blockrow,
dl.stats {
height:1%;
}
.floatcontainer,
.formcontrols .blockrow,
dl.stats {
display:block;
}
.blockrow {
padding:12px;
}
.blocksubhead {
padding:12px;
}
.blockhead_info, .blocksubhead_info {
float:right;
font-weight:normal;
}
Have you tried applying the float property to the .floatcontainer element?
.floatcontainer {
width: 50%;
float: left;
}
Setting the width property will be necessary here because the output of the script in the second .floatcontainer block adds a div element to the document which has a width of 100%. Take a look at the output here: http://goo.gl/Bw7iaD (see inline styles of first element). This makes the verse box span full-width unless it's parent container has a specified width.
Here is an example of the working code: http://cdpn.io/0dfce502ffdc99f54a159f7a563ed4fe

Trying to make a custom table [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I'm trying to make a table that looks like this:
But I'm not quite sure how to go about doing that.
The end result is supposed to look like this:
I was planning on having making a div, and then setting the background of the div to be the grey textured part, and then creating a table inside that div to organize the content. Is using a table in this situation correct? Or is there a better method? Thanks in advance.
Stick to a non-table markup. Best practices today would suggest you should only use tables for tabular data, and this content is not tabular data.
There's several different methods you could use to get this going, including using floats, displaying inline-block, and others. There's also considerations with the content wrapping around the images (if the content is long, for example).
But here's some sample code to get your rolling.
Styles:
div.left,
div.right {
width: 400px;
overflow: hidden; /* forces the div to clear the floated content */
}
div.left img,
div.right img {
border: 2px solid #888;
}
div.left img {
float: left;
padding-right: 20px;
}
div.right img {
float: right;
padding-left: 20px;
}
The html markup:
<div class="left">
<img src="your_image_source"><p>Lorem Ipsump dolor sit amet</p>
</div>
<div class="right">
<img src="your_image_source"><p>Lorem Ipsum dolor sit amet</p>
</div>
Here is a DEMO
This should show you exactly what you need.
<body>
<div id="topLeft"></div>
<div id="topRight"></div>
<div id="middleLeft"></div>
<div id="middleRight"></div>
<div id="bottomLeft"></div>
<div id="bottomRight"right></div>
</body>
body {
height:400px;
}
#topLeft {
background-color:#000000;
width:32%;
height:32%;
margin:5px;
float:left;
}
#topRight {
float:right;
background-color: #000000;
width:65%;
height:32%;
margin:5px;
}
#middleLeft {
background-color:#000000;
width:65%;
height:32%;
margin:5px;
float:left;
}
#middleRight {
float:right;
background-color: #000000;
width:32%;
height:32%;
margin:5px;
}
#bottomLeft {
float:left;
background-color: #000000;
width:32%;
height:32%;
margin:5px;
}
#bottomRight {
float:right;
background-color: #000000;
width:65%;
height:32%;
margin:5px;
}
The body can be replaced with a wrapper and sized appropriately.
Code on jsFiddle
Fooey on those haters who say don't use tables. I would totally use a table for this.
<table>
<tr>
<td colspan=1><img src="yadayada"></td>
<td colspan=2>Lorem Ipsum...</td>
</tr>
<tr>
<td colspan=2>Lorem Ipsum...</td>
<td colspan=1><img src="yadayada"></td>
</tr>
<tr>
<td colspan=1><img src="yadayada"></td>
<td colspan=2>Lorem Ipsum...</td>
</tr>
</table>

Div not filling width of floated container (css expert needed

I know there are many variations of this question posted, but none I've found quite provide an answer that works for this case.
I basically have two left floated divs. Inside those two divs are div headers and tabled content.
I want the Div headers (Hour/Minute) to stretch to the width of the tabled content, but they only do this in FF and Chrome, not IE7. IE7 is my works official browser so the one I need it to work with the most.
Here is the CSS:
#ui-timepicker-div { padding:0.2em; }
#ui-timepicker-hours { float:left; }
#ui-timepicker-minutes { margin:0 0 0 0.2em; float:left; }
.ui-timepicker .ui-timepicker-header { padding:0.2em 0; }
.ui-timepicker .ui-timepicker-title { line-height:1.8em; text-align:center; }
.ui-timepicker table { margin:0.15em 0 0 0; font-size:.9em; border-collapse:collapse; }
.ui-timepicker td { padding:1px; width:2.2em; }
.ui-timepicker th, .ui-timepicker td { border:0; }
.ui-timepicker td a {
display:block;
padding:0.2em 0.3em 0.2em 0.5em;
text-align:right;
text-decoration:none;
}
Here is the HTML (did not include tabled content):
<div style="position: absolute; top: 252.667px; left: 648px; z-index: 1; display: none;" class="ui-timepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all" id="ui-timepicker-div">
<div id="ui-timepicker-hours">
<div class="ui-timepicker-header ui-widget-header ui-helper-clearfix ui-corner-all">
<div class="ui-timepicker-title">Hour</div>
</div>
<table class="ui-timepicker">
</table>
</div>
<div id="ui-timepicker-minutes">
<div class="ui-timepicker-header ui-widget-header ui-helper-clearfix ui-corner-all">
<div class="ui-timepicker-title">Minutes</div>
</div>
<table class="ui-timepicker">
</table>
</div>
</div>
Sorry to answer my own question, but after literally hours on this I just found out that by removing the 'ui-helper-clearfix' class from the ui-timepicker-header, all now works well in IE7 and FF

css position relative to the image

I am trying to align a text Email and textbox for it on top of an image at a specific location. I want the position to be fixed, no matter what size the screen is. Here is my html code:
<html>
<head>
<style type="text/css">
#container {
background-color:blue;
}
#content {
background: url('images/orange.jpg') no-repeat center top;
}
#c_main {
color: yellow;
}
#c_email {
position:absolute;
top:200px;
left:410px;
color: #FFFFFF;
font-size: 15px;
}
#c_emailbox1 {
position:absolute;
top:200px;
left:480px;
}
#c_emailbox2 {
position:absolute;
top:200px;
left:620px;
color: white;
font-size: 12px;
}
input {
border:0;
}
.email_textbox1 {
width:130px;
background-image:url('images/text_bg.jpg');
background-repeat:no-repeat;
}
.email_textbox2 {
color: #FFFFFF;
font-size: 11px;
width:130px;
background-image:url('images/text_bg.jpg');
background-repeat:no-repeat;
}
</style>
</head>
<body>
<div id="container">
<div id="content" style="height:1000px;left:0px;border:1px solid red;position:relative" >
<div style="height:100px;width:200px;border:1px solid red;position:absolute;top:250px;left:0px">
<h4> CREATE A USERNAME AND PASSWORD </h4>
</div>
<div id="c_email">
Email
</div>
<div id="c_emailbox1">
<input type="textbox" id="email1" border="0" class="email_textbox1">
</div>
<div id="c_emailbox2">
<input type="text" id ="email" value="Confirm Email Address" class="email_textbox2" onfocus="if
(this.value==this.defaultValue) this.value='';">
</div>
</div>
</div>
</body>
</html>
I cannot get it to align relative to the image. The text and textbox are misplaced when seen in a larger screen or if zoomed in and out. Suggestion please.
See my sample code. This is working. Change the height of parent div, the child always stays at bottom:
<div style="height:300px;border:1px solid red;position:relative">
<div style="height:100px;width:20px;border:1px solid red;position:absolute;bottom:0px">
</div>
</div>
If you want them always to the top of the text box. Make the parent control as relative.
The box or anything which you want to maintain constant distance make it absolute position
.Container {
position:relative
}
.child{
position:absolute
bottom:0px; // how much u wants to maintain..from the element
}

Resources