I am a CSS newbie, maybe you laugh about my problem...
I have 2 main DIVs ("topinfo" and "navigat"), and I need them to stay separated, one after other, but for some reason they don't.
Running code on Fiddle: https://jsfiddle.net/7mgfrhq6/
Here is the HTML code:
<div id="topinfo">
<div id="infowin">
<div id="computer">
<b>Computer:</b> 123456789012345 (192.168.560.000)
<img src="http://i.imgur.com/Y1CJmSa.png" id="more"/>
</div>
</div>
<div id="statbtn">
<a href="stats.htm" target="_blank">
<img src="http://i.imgur.com/rh4XEOQ.png" id="bstats">
</a>
</div>
</div>
<div class="navigat">
« First
« Prior
<select class="navsel" onchange="self.location.href=options[selectedIndex].value">
<option selected="selected">Page 001</option>
<option value="pag002.htm">Page 002</option>
<option value="pag003.htm">Page 003</option>
<option value="pag004.htm">Page 004</option>
<option value="pag005.htm">Page 005</option>
</select>
Next »
Last »
</div>
Here is the CSS code:
#topinfo {
width: 420px;
margin: 16px auto 4px auto;
}
#topinfo #infowin {
float: left;
width: 380px;
border: 1px dotted #292929;
border-radius: 4px;
background-color: #FFFFE8;
}
#topinfo #infowin #computer {
padding: 6px;
font-family: Verdana, Tahoma, Helvetica;
font-size: 10pt;
text-align: center;
}
#topinfo #statbtn {
float: right;
width:32px;
height:32px;
border: 0;
}
.navigat {
width: 600px;
margin: 18px auto 14px auto;
font-family: Tahoma, Verdana, Helvetica;
text-align: center;
}
.navigat a.navbtn {
display: inline-block;
width:70px;
padding: 3px 3px 4px 3px;
margin: 3px;
font-size: 9pt;
color: #FFFFFF;
text-align: center;
text-decoration: none;
background-color: #1D63C8;
border-radius: 10px;
cursor: pointer;
}
.navigat select.navsel {
display: inline-block;
width:100px;
padding:3px;
margin: 3px;
font-size: 9pt;
line-height: 1;
cursor: pointer;
}
Here is what I got:
And here is what I really need:
Thanks for any help!
You need to clear the floats above when you get to .navigat and then add a bit of padding to get the desired spacing.
.navigat {
clear: both;
padding-top: 18px;
}
Recommended reading: Chris Coyier, All About Floats
This happens because of your float, you can solve this by adding an empty div in between "topinfo" and "navigat" with clear:both
HTML:
<div id="topinfo">
<div id="infowin">
<div id="computer">
<b>Computer:</b> 123456789012345 (192.168.560.000)
<img src="http://i.imgur.com/Y1CJmSa.png" id="more"/>
</div>
</div>
<div id="statbtn">
<a href="stats.htm" target="_blank">
<img src="http://i.imgur.com/rh4XEOQ.png" id="bstats">
</a>
</div>
</div>
<div class="clear"></div>
<div class="navigat">
« First
« Prior
<select class="navsel" onchange="self.location.href=options[selectedIndex].value">
<option selected="selected">Page 001</option>
<option value="pag002.htm">Page 002</option>
<option value="pag003.htm">Page 003</option>
<option value="pag004.htm">Page 004</option>
<option value="pag005.htm">Page 005</option>
</select>
Next »
Last »
</div>
CSS:
.clear
{
clear:both;
}
DEMO
This is happending because of the floats that you are using to align the div of #topinfo.
What you can do is make the inside as display:inline-block. So this will be something like this..
#topinfo #infowin {
display:inline-block
width: 380px;
border: 1px dotted #292929;
border-radius: 4px;
background-color: #FFFFE8;
}
#topinfo #statbtn {
display:inline-block;
width:32px;
height:32px;
border: 0;
vertical-align: bottom;
}
If you want to use floats you can use clear:both on .navigat class.
Related
I have read almost every post on here about divs not lining up side by side but none of them apply to me.
It seems like I am missing a float:left; on both blocks but for whatever reason, they are not honoring that. If I do float:right; to the right container, then it just pushes the right container under the left container.
So far I have tried css attributes:
float: right and left;
display: in-line;
display: block;
width of both left nav and right container
It seems to me like the "main container" is preventing the right container from moving up but, this div is inside that container. I have also tried z-index, and position.
what am I doing wrong here?
body {
font-family: Arial, Helvetica, sans-serif !important;
background: URL("http://www.mscdirect.com/global/application-content/images/header/ribbon-bg-1.gif") repeat-x scroll top left;
clear: both;
}
#header {}
#content-container {
width: 961px;
}
.top-container {
border-bottom: 1px solid #ccc;
cursor: pointer;
font-size: 14px;
font-weight: bolder;
margin: 5px 0px 0px 20px;
padding: 10px 0 18px;
text-align: center;
text-transform: uppercase;
}
.reg-text {
font-weight: normal;
text-transform: uppercase;
font-size: 12.5px;
cursor: pointer;
}
.red-text {
color: #db403b;
font-size: 18px;
text-transform: uppercase;
cursor: pointer;
}
.left-container {
width: 262px;
border: 1px solid #ccc;
margin: 20px 0px 0px 20px;
}
.left-nav {
width: 245px;
margin-top: 10px;
}
.left-nav-head {
text-transform: uppercase;
width: 208px;
margin: 0px 0px 6px 7px;
padding: 5px 20px 3px 14px;
font-size: 12px;
list-style-image: none;
color: #fff;
background: #345599;
}
.left-nav li {
background: rgba(0, 0, 0, 0) url("http://www.mscdirect.com/global/application-content/images/content/contentArrow2.gif") no-repeat scroll 16px 7px;
list-style: inside none none;
margin: 0px 0px 5px 5px;
padding: 4px 16px 6px 27px;
font-size: 13px
}
.right-container {
width: 662px;
display: block;
}
ul {
list-style: none;
}
li:nth-child(odd) .prod-text-box {
float: left;
}
li:nth-child(odd) .prod-img-box {
position: relative;
padding-right: 100px;
}
#main-container {
width: 961px;
margin: 0px auto;
}
a {
text-decoration: none;
color: #2866B1 !important;
font: bold 12px Arial, Helvetica, sans-serif !important;
text-decoration: none;
padding: 5px 0 5px
}
a:hover:visted:link {
color: #2866B1 !important;
font: bold 12px Arial, Helvetica, sans-serif !important;
text-decoration: none;
padding: 5px 0 5px
}
.product-content {
float: left;
border: 1px solid #ccc;
width: 664px;
margin-left: 300px
}
.prod-box {
width: 644px;
border-bottom: 1px solid #ccc;
float: left;
clear: both;
margin: 0px 0px 10px 13px;
min-height: 200px;
}
.prod-img-box {
overflow: hidden;
margin-top: 20px;
float: right;
position: absolute;
}
.prod-text-box {
width: 272px;
position: relative;
float: right;
clear: both;
}
.prod-title {
font-size: 26px;
color: #00337a;
line-height: 30px;
text-align: left;
padding-top: 10px;
clear: both;
}
.prod-cta {
color: #2866B1 !important;
font: bold 12px Arial, Helvetica, sans-serif !important;
text-decoration: none;
padding: 5px 0 5px;
clear: both;
}
</style> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script> <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.2/jquery.min.js"></script> <!-- IE is not seeing HTML5 tags so I added this to fix that --> <!--[if lt IE 9]> <script> document.createElement('header');
document.createElement('nav');
document.createElement('section');
document.createElement('article');
document.createElement('figure');
document.createElement('figcaption');
document.createElement('footer');
</script> <![endif]-->
<div id="main-container">
<div id="header"><img src="header.png" width="961px" height="144px"></div>
<div class="top-container">save up to <span class="red-text">25% </span>on orders over <span class="red-text">$249</span> + get free shipping when you order online.<span class="reg-text"> enter code:</span> ALL25H <span class="reg-text">click to apply ►</span></div>
<div id="content-container">
<div class="left-container">
<!-- Left Navigation -->
<div class="left-nav">
<div class="left-nav-head">Head Protection</div>
<ul>
<li>Hard Hats</li>
<li>Bump Caps</li>
<li>Welding Helmets</li>
<li>Face Sheilds</li>
<li>Winter Liners</li>
</ul>
</div>
<!-- Products Section -->
<div class="right-container">
<div class="product-content">
<ul>
<li>
<a name="hardhat"></a>
<div class="prod-box">
<div class="prod-text-box">
<div class="prod-title">Hard Hats</div>
Protect yourself from minor head and neck injuries with the comfort and reliability of bump caps. Choose from a variety of styles, colors, and adjustment types.
<div class="prod-cta">Shop Bump Caps<span>►</span></div>
</div>
<div class="prod-img-box"><img src="images/hardhat.jpg" alt="Hard Hats"></div>
</div>
</li>
<li>
<a name="bumpcaps"></a>
<div class="prod-box">
<div class="prod-text-box">
<div class="prod-title">Bump Caps</div>
Protect yourself from minor head and neck injuries with the comfort and reliability of bump caps. Choose from a variety of styles, colors, and adjustment types.
<div class="prod-cta"><a class="prod-cta" href="/browse/tn/Safety/Personal-Protective-Equipment/Hard-Hats-Bump-Caps/Bump-Caps?navid=12106709&rdrct=Bump+Caps&intcmp=BumpCaps_SafetyHeadProtectionStaticPage_CTA_April2016_v1">Shop Bump Caps<span>►</span></a></div>
</div>
<div class="prod-img-box"><img src="images/hardhat.jpg" alt="Hard Hats"></div>
</div>
</li>
<li>
<a name="bumpcaps"></a>
<div class="prod-box">
<div class="prod-text-box">
<div class="prod-title">Bump Caps</div>
Protect yourself from minor head and neck injuries with the comfort and reliability of bump caps. Choose from a variety of styles, colors, and adjustment types.
<div class="prod-cta"><a class="prod-cta" href="/browse/tn/Safety/Personal-Protective-Equipment/Hard-Hats-Bump-Caps/Bump-Caps?navid=12106709&rdrct=Bump+Caps&intcmp=BumpCaps_SafetyHeadProtectionStaticPage_CTA_April2016_v1">Shop Bump Caps<span>►</span></a></div>
</div>
<div class="prod-img-box"><img src="images/hardhat.jpg" alt="Hard Hats"></div>
</div>
</li>
<li>
<a name="bumpcaps"></a>
<div class="prod-box">
<div class="prod-text-box">
<div class="prod-title">Bump Caps</div>
Protect yourself from minor head and neck injuries with the comfort and reliability of bump caps. Choose from a variety of styles, colors, and adjustment types.
<div class="prod-cta"><a class="prod-cta" href="/browse/tn/Safety/Personal-Protective-Equipment/Hard-Hats-Bump-Caps/Bump-Caps?navid=12106709&rdrct=Bump+Caps&intcmp=BumpCaps_SafetyHeadProtectionStaticPage_CTA_April2016_v1">Shop Bump Caps<span>►</span></a></div>
</div>
<div class="prod-img-box"><img src="images/hardhat.jpg" alt="Hard Hats"></div>
</div>
</li>
<li>
<a name="bumpcaps"></a>
<div class="prod-box">
<div class="prod-text-box">
<div class="prod-title">Bump Caps</div>
Protect yourself from minor head and neck injuries with the comfort and reliability of bump caps. Choose from a variety of styles, colors, and adjustment types.
<div class="prod-cta"><a class="prod-cta" href="/browse/tn/Safety/Personal-Protective-Equipment/Hard-Hats-Bump-Caps/Bump-Caps?navid=12106709&rdrct=Bump+Caps&intcmp=BumpCaps_SafetyHeadProtectionStaticPage_CTA_April2016_v1">Shop Bump Caps<span>►</span></a></div>
</div>
<div class="prod-img-box"><img src="images/hardhat.jpg" alt="Hard Hats"></div>
</div>
</li>
</ul>
</div>
</div>
</div>
</div>
</div>
You currently have your markup set up like this:
<container>
<left-container>
<left-nav></left-nav>
<right-container></right-container>
</left-container>
</container>
It needs to be:
<container>
<left-container>
<left-nav></left-nav>
</left-container>
<right-container></right-container>
</container>
The left-container does not span the entire width of the container. From there you add
float: left;
to your left-nav and
float: right;
to your right-container and you should be all set!
What #kiaanabal said and a position absolute in your css on the left container would be quite useful too.
.left-container {
position: absolute;
width: 262px;
border: 1px solid #ccc;
margin: 20px 0px 0px 20px;
float: left;
overflow: auto;
}
http://codepen.io/Thrizian/pen/zBOZNE?editors=1100
I am working on a simple html/css web page.
What I am trying to do is having an image and a div. Both will be inline display and in div I want to put a link. But when I put a long link title it is not what I expect it to be.
My code is this-
code
<div class="heading"> featured posts
</div>
<div class="img_src">
<img style="height:120px;" src="/uploads/1.jpg"></img>
</div>
<div class="link_src">
<a class="inside_link" href="#">Link will go here but if there is a long title then it may create some problems..</a>
</div>
</div>
CSS-
.img_src{
display: inline-block;
margin-top: 3px;
margin-left:-2%;
}
.link_src{
display: inline-block;
background-color: white;
height: 120px;
line-height: 120px;
width: 61%;
margin-top: 3px;
text-transform: uppercase;
}
.inside_link{
margin-left: 2%;
margin-right: 2%;
font-size: 15px;
}
.heading{
display: block;
background-color: #000;
color: #fff;
font-family: "Roboto Condensed","HelveticaNeue-CondensedBold","Helvetica Neue",Helvetica,Arial,Geneva,sans-serif;
font-size: 20px;
margin-top:5px;
font-color:white;
margin-left:-2%;
margin-right:-2%;
text-align: center;
line-height: 40px;
height: 40px;
font-style: oblique;
text-transform: uppercase;
}
I searched on google and StackOverflow but I did not get anything useful.
I want it to look like this(DIV wraps full)-
Any suggestion?
You csn use diplay:table-cell instead of inline-block but also I made edit in html by adding div.post that contain the image and title, and remove the inline-style that gave height to the image
<div class="post">
<div class="img_src">
<img src="http://i.dailymail.co.uk/i/pix/2016/03/22/13/32738A6E00000578-3504412-image-a-6_1458654517341.jpg">
</div>
<div class="link_src">
<a class="inside_link" href="#">Link will go here but if there is a long title then it may create some problems..</a>
</div>
</div>
and in the css I give width:20%; to .img_src and width:80%; to .link_src (you can change the widths as you like) and remove height and line height from them and the diplay:table-cell will handle those height
.post{
font-size:0;
display:table;
width:100%;
}
.img_src{
display: table-cell;
vertical-align:top;
width:20%;
}
.img_src img{
width:100%;
}
.link_src{
display: table-cell;
background-color: white;
margin-top: 3px;
text-transform: uppercase;
vertical-align:middle;
width:80%;
}
.inside_link{
margin-left: 2%;
margin-right: 2%;
font-size: 15px;
}
.heading{
display: block;
background-color: #000;
color: #fff;
font-family: "Roboto Condensed","HelveticaNeue-CondensedBold","Helvetica Neue",Helvetica,Arial,Geneva,sans-serif;
font-size: 20px;
margin-top:5px;
font-color:white;
margin-left:-2%;
margin-right:-2%;
text-align: center;
line-height: 40px;
height: 40px;
font-style: oblique;
text-transform: uppercase;
}
https://jsfiddle.net/IA7medd/gg7ygdLs/17/
You can achieve that by changing the inline-block display to table-cell and then apply the vertical-align:middle; property on the text container.
That way, the text will be perfectly vertically centered if there are one, two, three lines of content.
.parent{
display: table;
border: 5px solid #ccc;
width: 100%;
}
.img_src{
display: table-cell;
}
.link_src{
display: table-cell;
vertical-align: middle;
background-color: white;
width: 61%;
text-transform: uppercase;
}
See this fiddle
Ok you are using the wrong approach. Line height is causing you the problem. Your html should look like this
<img class="img_src" style="height:120px;" src="/uploads/1.jpg">
<div class="link_src">
<div class="inner_link_src">
<div class="inner_margin">
Link will go here but if there is a long title then it may create some problems..
</div>
</div>
</div>
and your css like this
.img_src{
float:left
}
.link_src{
float:left;
position:relative;
width: 61%;
text-transform: uppercase;
background-color: white;
vertical-align: top;
display:table;
height:120px;
}
.inner_link_src{
display:table-cell;
width:100%;
height:100%;
vertical-align:middle;
margin-left:10px;
}
.inner_margin{
margin-left:10px;
}
see the jsfiddle it is working great
https://jsfiddle.net/gg7ygdLs/27/
You just change your CSS and HTML by following and then you get the desired result.
CSS:
.img_src{
display: inline-block;
margin-top: 3px;
margin-left:-2%;
}
.link_src{
display: inline-block;
background-color: white;
height: 120px;
width: 100%;
margin: 10px 0 10px 3px;
-webkit-box-shadow: 7px 0px 0px 3px rgba(204,204,204,1);
-moz-box-shadow: 7px 0px 0px 3px rgba(204,204,204,1);
box-shadow: 7px 0px 0px 3px rgba(204,204,204,1);
}
.inside_link{
margin: 2%;
display: inline-block;
position:absolute;
padding: 8px;
}
.heading{
display: block;
background-color: #000;
color: #fff;
font-family: "Roboto Condensed","HelveticaNeue-CondensedBold","Helvetica Neue",Helvetica,Arial,Geneva,sans-serif;
font-size: 20px;
margin-top:5px;
font-color:white;
margin-left:-2%;
margin-right:-2%;
text-align: center;
line-height: 40px;
height: 40px;
font-style: oblique;
text-transform: uppercase;
}
HTML:
<div class="heading"> featured posts
</div>
<div class="link_src">
<img style="height:120px;" src="http://smashinghub.com/wp-content/uploads/2011/11/Text-Shadow-Box.jpg" />
<a class="inside_link" href="#">Link will go here but if there is a long title then it may create some problems..</a>
</div>
Demo
You can simplify your code a lot by using Flexbox.
You can use it for your header as well, to center the title.
.your-header {
display: flex;
align-items: center;
justify-content: center;
}
Then the image container. Use it's more semantic and it's a block element, perfect to wrap an image with a caption or a link in your case:
<figure class="your-figure">
<img class="your-image" src="http://pipsum.com/200x150.jpg"></img>
<a class="your-link" href="#">Link will go here but if there is a long title then it may create some problems..</a>
</figure>
and the CSS
.your-figure {
display: flex;
align-items: center;
padding: 4px;
border: 1px solid #ccc;
background-color: #fff;
}
.your-image {
margin-right: 10px;
}
Have a look here for the complete code ;)
Follow this if you don't know Flexbox, might seems daunting at first, but when it clicks in your head it will change your life :) Complete guide to Flexbox
I'm using this CSS track to get the hang of what's happening in the browser. However, the last assignment was an incomplete success. How can I push the post-updates section not only right, but to the top of the page?. (So far I've tried position: absolute without much luck).
ed: Both answers helped, I am grateful.
You can try this:
Working Fiddle here
#post-update {
position:absolute;
top:0; right:0;
}
Good Luck...
The <div id="post-update"> needs to be floated right and the width of the header narrowed to fit in the screen.
JSFiddle Demo
HTML
<div id="content">
<div id="header">
<h1 id="stf">Stanford Connection</h1>
<img src="//i62.tinypic.com/i2onyf.gif" alt="I'm a tree"/>
</div>
<div id="about">
<img src="//i62.tinypic.com/2vnkmtl.jpg" alt="Molly"/>
<h2 class="section-heading">About Me</h2>
<p><strong>Birthday:</strong> December 8, 2001</p>
<p><strong>Gender:</strong> Female</p>
<h2 class="section-heading">Friends</h2>
<p><strong>Patrick Young</strong></p>
<p><strong>Chloe Cox</strong></p>
</div>
<div id="updates">
<h1>Molly the FloPup</h1>
<h2 class="section-heading">Status Updates</h2>
<p>When am I going to get fed?</p>
<p>I want to go for a walk. </p>
<p>There's a squirrel on the patio, why won't Patrick let me chase it? </p>
<p>I really like summer, because I get to sun myself on the patio </p>
</div>
</div>
<div id="post-update">
<h2 class="section-heading">Post Updates</h2>
<form action="">
<textarea name="" id="" cols="30" rows="10"></textarea>
<br>
<input type="button" value="Submit New Update" align="left"/>
</form>
</div>
CSS
body {
padding: 0.5em;
}
strong {
font-weight: bold;
}
h1 {
font-size: 32pt;
text-indent: 1em;
padding-top: 0.3em;
padding-bottom: 0.3em;
}
#stf {
margin-left:1em;
line-height: 2.5em;
display: inline;
vertical-align: top;
}
#content {
width:50em;
float:left;
}
#header {
background-color: #9A0000;
color: white;
height: 120px;
}
#header img {
display: inline;
vertical-align: top;
float: right;
}
.section-heading {
border-top: 3px solid black;
border-bottom: 3px solid black;
background-color: #CC9191;
font-size: 13pt;
padding-left: 0.5em;
padding-bottom: 0.3em;
padding-top: 0.3em;
margin-bottom: 0.5em;
margin-top: 0.5em;
}
#about {
width: 200px;
font-family: sans-serif;
font-size: 12pt;
float: left;
}
#about img {
margin-top: 7px;
}
#updates {
/* background: #AA4; */
float:left;
margin-left:10px;
}
#updates p {
border-top: 2px solid black;
line-height: 2em;
}
#post-update {
float: right;
}
textarea {
width: 17em;
height: 7em;
}
I'm admitting right at the start: this is my first attempt at HTML/CSS coding. So please excuse my code's messiness.
I have two problems: 1. When I shrink my browser window small enough to see a scroll bar, my three drop down menus disappear. 2. I am trying to center my button (Find Resources), but can't figure it out. I've tried auto-ing my left and right margins, I tried text aligning, but it messed up the placement of my three boxes (which have a width of 200px).
Thanks for any help someone can offer!
HTML:
<div id="resource-wrapper">
<div id="content">
<p class="resource-p">Welcome to Our Resource Center.</p>
<p class="resource-p">How may we help you?</p>
</div>
<div id=buttons-div>
<div id=select>
<select class="dropdown" name="field_related_brands_nid">
<option value="All" selected="selected">Any</option>
<option value="2511">Sample</option>
</select>
<select class="dropdown-2" name="field_related_technology_nid">
<option value="All" selected="selected">Any</option>
<option value="444">Sample</option>
</select>
<select class="dropdown-3" name="field_resource_type_value_many_to_one">
<option value="All" selected="selected">Any</option>
<option value="multimedia">Sample</option>
</select>
</div>
<div id=buttons>
<img src="Images/Buttons1.jpg" class="resource-image">
<img src="Images/Buttons2.jpg" class="resource-image">
<img src="Images/buttons3.jpg" class="resource-image">
</div>
<button type="submit" class="resource-p1">Find Resources</button>
</div>
</div>
CSS:
#resource-wrapper {
width: 850px;
margin: 0 auto;}
#content {
background-color: #669bcf;
padding: 1px;
width: 100%;}
.resource-p {
text-align: center;
font-size: 30px;
font-family: sans-serif;
color: white;
line-height: 15px}
#buttons-div {
position: relative;
width: 850px;}
#select {
position: fixed;
margin-top: 214px;
width: 850px;}
.dropdown {
width: 160px;
margin-left: 78px;}
.dropdown-2 {
width: 125px;
margin-left: 115px;}
.dropdown-3 {
width: 95px;
margin-left: 148px;}
.resource-image {
margin: 50px 0 0 58px;}
.resource-p1 {
padding: 16px 18px 13px 18px;
margin: 20px;
text-align: center;
font-size: 21px;
font-family: sans-serif;
color: white;
font-weight: bold;
background-color: #669bcf;
border-style: solid;
border-width: 1px 1px 3px 1px;
border-color: #d7e4f4;
border-radius: 5px;}
Your Dropdowns shouldn't stack as nothing is responsive in your site. If they have a set width like width: 800px; They should be fine. However make sure to have all your id's surrounded with a quote:
<div id=buttons-div>
should be
<div id="buttons-div">
To Center your Resource Button:
.resource-p1 {
margin: 12px auto;
text-align: center;
font-size: 21px;
font-family: sans-serif;
color: white;
font-weight: bold;
background-color: #669bcf;
border-style: solid;
border-width: 1px 1px 3px 1px;
border-color: #d7e4f4;
border-radius: 5px;
display: block;
}
DEMO
1) Change #select's position from fixed to absolute
2) Wrap your button in a container and give that container text-align:center
HTML
<div id="find-resources-container">
<button type="submit" class="resource-p1">Find Resources</button>
</div>
CSS
#find-resources-container {
text-align:center
}
I have container div (gray box) with floating elements inside:
Bars are floating to the left and button if floating to the right. Now I want textbox to fill the empty space between the bars and the button.
Please note that bars count may vary during typind so textbox should be able to resize accordingly. So solutions with static widths (even if they are expressed in %) will not work.
How can I do it?
EDIT:
Here's my code:
HTML:
<div id="dp-container">
<ol id="tag-list">
<li dp-item class="dp-bar-table">sales</li>
<li dp-item class="dp-bar-field">cost</li>
</ol>
<input id="dp-input-str" type="text">
<input type="button" value="GO" style="float: right;">
<div style="clear:both;"></div>
</div>
CSS:
body {
font-family: "Lucida Grande", Verdana, Arial, Helvetica, sans-serif;
}
ol {
display: inline;
margin: 0;
padding: 0;
vertical-align: middle;
list-style-type: none;
}
li[dp-item] {
background-color: #e0ffff;
display: inline-block;
float: left;
padding: 3px;
margin: 2px;
background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#FEFEFE), to(#EBEBEB));
border: 1px solid lightgray;
border-radius: 3px;
}
.dp-bar-table {
color: blue;
font-weight: bold;
}
.dp-bar-field {
color: blue;
}
#dp-input-str {
border: none;
display: inline-block;
margin-left: 5px;
margin-top: 3px;
width: auto;
outline: none;
font-size: 12pt;
vertical-align: middle;
line-height: 25px;
box-shadow: none;
#dp-container {
display: inline-block;
border: 1px solid #d3d3d3;
height: 32px;
padding: 3px;
width: 90%;
}
#dp-find-str {
color: gray;
float: left;
margin-top: 10px;
margin-right: 8px;
}
May be that's you want check this http://jsfiddle.net/bYmM4/7/ . Write like this:
HTML
<div class="main">
<input type="button" value="test" />
<input type="button" value="test" />
<input type="button" value="Go" class="go"/>
<div class="textbox">
<input type="text" />
</div>
</div>
CSS
.main{position:relative; border:#333 1px solid}
input[type="button"]{width:8%; float:left;}
.textbox{
background-color:grey;
overflow:hidden;
position:relative;
}
.textbox input{
width:100%;
-moz-box-sizing:border-box;
-webkit-box-sizing:border-box;
box-sizing:border-box;
}
input.go{float:right}