Solved

Floating DIV

Posted on 2014-01-30
10
377 Views
Last Modified: 2014-01-30
I have 2 divs that float side by side. I want the div on the right side to be able to expand down if the content is wider than the div.

Current for some reason the div expands but it goes under the div on the right, and I want to keep the div on the same place.

Something like this.
*-----------------------*
* DIV 1   --   DIV 2 *
*-------------   DIV 2 *
                 *  DIV 2 *
                 * ---------*
0
Comment
Question by:Medrise
  • 6
  • 4
10 Comments
 
LVL 58

Expert Comment

by:Gary
ID: 39821959
Not sure what you mean. How does your code differ from this
http://jsfiddle.net/5UvY9/
0
 

Author Comment

by:Medrise
ID: 39822036
Its something like that but I have this on my code

<div id="main" class="left">
    <div class="left">
           Div 1
    </div>
    <div class="wrap left">
           <div class="left">
                  Div 2
           </div>
           <div class="left">
                  Div 3 <br/>
                  Div 3 <br/>
                  Div 3 <br/>
           </div>
    </div>
</div>

Open in new window


Div 3 goes under the div2
0
 
LVL 58

Expert Comment

by:Gary
ID: 39822053
And what css do you have?
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:Medrise
ID: 39822074
Here is all the css and code

<div class="clearCSS prodDisplay">
	<div class="subGroup left">
		<div class="icon left">
			ICON
		</div>
		<div class="left smallPaddingLeft">
			INPUT
		</div>
		<div class="left medPaddingLeft smallPaddingRight">
			LINK
		</div>
		<div class="partNumandDesc left">
			<div class="medPaddingLeft partNumber left">
				DIV 1
			</div>
			<div class="prodDesc left">
				DIV 2<br/>
				DIV 2<br/>
				DIV 2<br/>
				DIV 2<br/>
				DIV 2<br/>
			</div>
		</div>
		<div class="left extraPaddingRight">
			some text
		</div>
		<div class="left leadTime medPaddingLeft">
			some text
		</div>
	</div>
</div>



.prodWrap {
	margin: 0;
}
.prodWrap .spacing {
	margin: 0 38px 0 38px;
}
.prodWrap .shippingLocation {
	text-align: right;
	font-weight: bold;
}
.prodWrap .header {
	width: 89%;
	margin-left: 32px;
	padding: 5px 25px 5px 25px;
	border-bottom:1px solid #990000;
	border-top:1px solid #990000;
}
.prodWrap .centerText {
	text-align: center;
}
.prodWrap .left {
	float: left;
}
.prodWrap .nomargin {
	margin-left: -15px;
}
.prodWrap .headerText {
	font-weight: bold;
	font-size: 12px;
}
.prodWrap .smallPaddingRight {
	padding-right: 10px;
}
.prodWrap .smallPaddingLeft {
	padding-left: 10px;
}
.prodWrap .medPaddingRight {
	padding-right: 20px;
}
.prodWrap .medPaddingLeft {
	padding-left: 20px;
}
.prodWrap .largePaddingRight {
	padding-right: 430px;
}
.prodWrap .extraPaddingRight {
	padding-right: 45px;
}
.prodWrap .clearCSS {
	clear: both;
}
.prodWrap .prodDisplay {
	padding-left: 32px;
}
.prodWrap .prodDisplay .subGroup {
	width: 980px;
	padding-top: 5px;
	padding-bottom: 5px;
}
.prodWrap .prodDisplay .subGroup .icon {
	margin: 0 auto;
	width: 30px;
}
.prodWrap .prodDisplay .subGroup .partNumandDesc .partNumber {
	font-size: 12px;
	font-weight: bold;
}
.prodWrap .prodDisplay .subGroup .partNumandDesc .prodDesc {
	font-size: 13px;
}
.prodWrap .prodDisplay .subGroup .leadTime {
	font-size: 12px;
}
.prodWrap .prodDisplay .subGroup .partNumandDesc {
	min-width: 630px !important;
	max-width: 630px !important;
}

Open in new window

0
 

Author Comment

by:Medrise
ID: 39822085
It works on JSFiddle must be some other css override.
0
 
LVL 58

Expert Comment

by:Gary
ID: 39822091
You are targeting those divs starting with an element that has a class prodWrap - but your code doesn't have an element with that class.
Wrap the html in a div with that class and your css will work fine.
http://jsfiddle.net/GaryC123/5UvY9/2/

At least I assume this is what you are looking for.
0
 

Author Comment

by:Medrise
ID: 39822146
I added that... it was missing on the code here... but the problem is that you have the <br/> after each text... and I don't have that on the original text... if I add the <br> it works. but I don't know how long the text is.
0
 

Author Comment

by:Medrise
ID: 39822167
Here is an example.
http://jsfiddle.net/5UvY9/3/
0
 
LVL 58

Accepted Solution

by:
Gary earned 500 total points
ID: 39822220
That's how div's work - they will take the maximum space they can (when floated) upto the width of the container, even if that means moving the whole div down.
To fix is it you need to give the div a max-width attribute, See in the example here
http://jsfiddle.net/GaryC123/5UvY9/4/
0
 

Author Comment

by:Medrise
ID: 39822256
Oh, ok... I got it now... that fixed... thanks :)
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In this tutorial viewers will learn how to style a decorative dropcap for the first letter in a paragraph using CSS. In CSS, create a new paragraph class by typing "p.fancy": Then, to style only the first letter of the first sentence, include the ps…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question