[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Floating DIV

Posted on 2014-01-30
10
Medium Priority
?
390 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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 2000 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
In this tutorial viewers will learn how to style rounded corners for elements in CSS using the border-radius property Begin with a normal styled element such as a div: To style all four corners of the div to be the same degree of roundness, use the …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Suggested Courses

830 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