Solved

Floating DIV

Posted on 2014-01-30
10
372 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
Comment Utility
Not sure what you mean. How does your code differ from this
http://jsfiddle.net/5UvY9/
0
 

Author Comment

by:Medrise
Comment Utility
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
Comment Utility
And what css do you have?
0
 

Author Comment

by:Medrise
Comment Utility
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
Comment Utility
It works on JSFiddle must be some other css override.
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 58

Expert Comment

by:Gary
Comment Utility
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
Comment Utility
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
Comment Utility
Here is an example.
http://jsfiddle.net/5UvY9/3/
0
 
LVL 58

Accepted Solution

by:
Gary earned 500 total points
Comment Utility
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
Comment Utility
Oh, ok... I got it now... that fixed... thanks :)
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

As a result of several questions about how to use Bootstrap I thought it would be a good idea to write down the development aspect of creating a Bootstrapped website in as little time as possible. Part 1 of this article will only concentrate on g…
So you have coded your own WordPress plugin and now you want to allow users to upload images to a folder in the plugin folder rather than the default media location? Follow along and this article will show you how to do just that!
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…
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 …

763 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now