I'm so confused by why margin-top will not work. Here is my code:
HTML:
<div class="container-extended-blog">
<div class="offers-for-week">
<h1 class="title offers-for-this-week">offers for this week</h1>
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.</p>
<img src="img/extended_blog_pic.jpg" alt="image of recipe">
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.</p>
</div><!-- /.offers-for-week -->
</div><!-- /.container-extended-blog -->
SCSS:
.container-extended-blog {
margin-top: 200px;
margin-left: 300px;
background-color: $blue-ot;
width: 350px;
height: 450px;
overflow: hidden;
p {
font-family: $content-font;
color: $icon-font-color;
}
}
I have tried adding position: relative; which I find usually works whenever something like this happens, however I have no idea why this isn't working, and would really like to understand!
add position:absolute; to .container-extended-blog
.container-extended-blog {
top: 200px;
margin-left: 300px;
background-color: $blue-ot;
width: 350px;
height: 450px;
overflow: hidden;
position:absolute;
}
OR
Change top: 200px; to margin-top: 200px;
.container-extended-blog {
margin-top: 200px;
margin-left: 300px;
background-color: $blue-ot;
width: 350px;
height: 450px;
overflow: hidden;
}
see fiddle at : http://jsfiddle.net/Q5xdf/
Related
I read a few comments and added an image, because I was not clear, sorry and thanks for your help!
I wanted to make a website with a rectangular border containing all the information, but this container should have the border opened on top and on the bottom. I have an image as a background, so I cannot make a simple div to hide some parts of the container. Of course this container should be responsive.
I thought it would be easy but I'm working all around this problem and cannot make it work.
Thanks in advance!
I want to make this: https://ibb.co/dmwP8PM
Please make changes on this test:
https://codepen.io/soporo123/pen/WNNxLmX
<style type="text/css">
body{
background: url(https://www.gohawaii.com/sites/default/files/styles/image_gallery_bg_xl/public/hero-unit-images/11500_mauibeaches.jpg?itok=I2TvGlCa) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
color: #FFF;
text-align: center;
}
.container{
width: 94%;
padding: 3em;
margin: 3%;
border: 5px solid #FFF;
box-sizing: border-box;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
position: relative;
}
.logo{
position: absolute;
top: -15px;
left: 0;
right: 0;
margin: auto;
}
.logo2{
position: absolute;
bottom: -15px;
left: 0;
right: 0;
margin: auto;
}
</style>
<body>
<div class="container">
<div class="logo">LOGO</div>
<h1 class="title">Lorem ipsum</h1>
<div class="text">
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.</p>
<p>Lorem ipsum dolor sit amet, cons ectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.</p>
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.</p>
<p>Lorem ipsum dolor sit amet, cons ectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.</p>
</div>
<div class="logo2">LOGO 2</div>
</div>
</body>
border-left and border-right should get you there.
body{
background: url(https://www.gohawaii.com/sites/default/files/styles/image_gallery_bg_xl/public/hero-unit-images/11500_mauibeaches.jpg?itok=I2TvGlCa) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
color: #FFF;
text-align: center;
}
.container{
width: 94%;
padding: 3em;
margin: 3%;
/***************************/
/* Change Here */
/***************************/
border-left: 5px solid #FFF;
border-right: 5px solid #FFF;
/**** END CHANGE ************/
box-sizing: border-box;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
position: relative;
}
.logo{
position: absolute;
top: -15px;
left: 0;
right: 0;
margin: auto;
}
.logo2{
position: absolute;
bottom: -15px;
left: 0;
right: 0;
margin: auto;
}
<div class="container">
<div class="logo">LOGO</div>
<h1 class="title">Lorem ipsum</h1>
<div class="text">
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.</p>
<p>Lorem ipsum dolor sit amet, cons ectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.</p>
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.</p>
<p>Lorem ipsum dolor sit amet, cons ectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.</p>
</div>
<div class="logo2">LOGO 2</div>
</div>
Alternatively you could use border-style: solid none
body {
background: url(https://www.gohawaii.com/sites/default/files/styles/image_gallery_bg_xl/public/hero-unit-images/11500_mauibeaches.jpg?itok=I2TvGlCa) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
color: #FFF;
text-align: center;
}
.container {
width: 94%;
padding: 3em;
margin: 3%;
border: 5px solid #FFF;
/** ONE LINE CHANGE BELOW **/
border-style: solid none;
box-sizing: border-box;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
position: relative;
}
.logo {
position: absolute;
top: -15px;
left: 0;
right: 0;
margin: auto;
}
.logo2 {
position: absolute;
bottom: -15px;
left: 0;
right: 0;
margin: auto;
}
<div class="container">
<div class="logo">LOGO</div>
<h1 class="title">Lorem ipsum</h1>
<div class="text">
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip
ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit
augue duis dolore te feugait nulla facilisi.</p>
<p>Lorem ipsum dolor sit amet, cons ectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip
ex ea commodo consequat.</p>
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip
ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit
augue duis dolore te feugait nulla facilisi.</p>
<p>Lorem ipsum dolor sit amet, cons ectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip
ex ea commodo consequat.</p>
</div>
<div class="logo2">LOGO 2</div>
</div>
You may use a gradient to draw partially the top and bottom borders to give room to the logos:
background:
linear-gradient(to left, white 40%, transparent 40%, transparent 60%, white 60%) top no-repeat,
linear-gradient(to left, white 40%, transparent 40%, transparent 60%, white 60%) bottom no-repeat;
background-size: 100% 5px;
your pen forked : https://codepen.io/gc-nomade/pen/xxxOMwK
If I'm understanding your question correctly
.container{
border-top:0;
border-bottom:0;
}
We have this right now but it has to be like this:
https://postimg.org/image/cw2e572zh/
I'm doing this for school and I can't figure it out the columns keep being 2x3 and not 3x2.
http://prntscr.com/crc7ln
<!DOCTYPE HTML>
<html>
<head>
<meta charset=utf-8>
<title>HTML CSS exercise - create a CSS Grid</title>
</head>
<body>
<div class="container">
<div class="row">
<div class="col1">
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.</p>
</div>
<div class="col2">
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.</p>
</div>
<div class="col3">
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.</p>
</div>
</div>
<div class="row">
<div class="col1">
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.</p>
</div>
<div class="col2">
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.</p>
</div>
<div class="col3">
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.</p>
</div>
</div>
</div>
</body>
</html>
/* CSS */
.row {
float: left;
position: relative;
box-sizing: border-box;
width: 24%;
padding-left: 10px;
}
.col1 {
left: 5px;
border: 2px solid black;
margin-bottom: 10px;
}
.col2 {
left: 15px;
border: 2px solid black;
margin-bottom: 20px;
}
.col3 {
left: 25px;
border: 2px solid black;
}
body {
border-width: 0px;
padding: 0px;
margin: 0px;
font-size: 90%;
background-color: #e7e7de
}
Here you go, try to avoid floats as they seem to mess up the way your div's flow sometimes. I've applied the 24% on the columns rather than the row, also I took out the repetitive declaration of styles. I'd suggest putting the same class on the columns rather than col1, col2 and col3
<!DOCTYPE HTML>
<html>
<head>
<meta charset=utf-8>
<title>HTML CSS exercise - create a CSS Grid</title>
<style>
.row {
box-sizing: border-box;
padding-left: 10px;
}
.col1, .col2, .col3 {
left: 5px;
border: 2px solid black;
margin-bottom: 10px;
display: inline-block;
padding: 5px;
width: 24%;
}
body {
border-width: 0px;
padding: 0px;
margin: 0px;
font-size: 90%;
background-color: #e7e7de
}
</style>
</head>
<body>
<div class="container">
<div class="row">
<div class="col1">
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.</p>
</div>
<div class="col2">
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.</p>
</div>
<div class="col3">
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.</p>
</div>
</div>
<div class="row">
<div class="col1">
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.</p>
</div>
<div class="col2">
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.</p>
</div>
<div class="col3">
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.</p>
</div>
</div>
</div>
</body>
</html>
You do realise you have 2 divs with 3 divs in it... Pretty logical you're having 2x3 then and not 3x2, perhaps you want 3 divs with 2 divs in them?
Apply these style, reducing the amount of code.
<style>
.row {
border:1px solid red;
float:left;
}
.column{
float:left;
margin:10px;
border:1px solid black;
width:24%;
}
.clear{clear:both;}
With following structure of HTML
<div class="container">
<div class="row">
<div class="column">
<p>loren ipsum</p>
</div>
<div class="column">
<p>loren ipsum</p>
</div>
<div class="column">
<p>loren ipsum</p>
</div>
</div>
<div class="clear"></div>
<div class="row">
<div class="column">
<p>loren ipsum</p>
</div>
<div class="column">
<p>loren ipsum</p>
</div>
<div class="column">
<p>loren ipsum</p>
</div>
</div>
</div>
I need some help...
I am trying to style a blockquote elemet:
<div class="container-fluid testimonials padding">
<div class="row-fluid">
<div class="col-xs-12 col-sm-12 col-md-5 col-md-offset-2 col-lg-5 col-lg-offset-2">
<blockquote>
Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vul. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vul.
</blockquote>
</div>
<div class="col-xs-12 col-sm-12 col-md-3 col-lg-3">
</div>
</div>
</div>
Styling I have so far:
.padding {padding-top:2%;padding-bottom:2%;}
blockquote {padding:60px 30px 40px 95px;border:none;position:relative;font-family: 'Comfortaa', cursive;}
blockquote::before{
content: "\201C";
font-family: 'Comfortaa', cursive;
font-size: 180px;
font-weight: bold;
color: #999;
position: absolute;
left:20px;
top:-40px;
color:#b80072;
z-index: -1;
}
blockquote::after{
content: "\201D";
font-family: 'Comfortaa', cursive;
font-size: 180px;
font-weight: bold;
color: #999;
position: absolute;
right:5%;
bottom:-45%;
color:#b80072;
z-index: -1;
opacity:0.5;
width:90px;
}
#media (max-width: 510px) {
blockquote::after {bottom:-25%;}
}
The result is almost what I want to achieve.
The before pseudo element is styled correctly and the blockquote padding itself is fine.
The problem is styling the after pseudo element as. How do I get it to stick to the bottom right hand corner of the blockquote element?
Any help would be appreciated.
The reason the placement seems difficult is because of the huge default line height on the quote marks. You can get a bit more control of it by setting
blockquote::after {line-height: 0;}
... though it's not an ideal solution.
I want to make the "more information" element to appear inside the div. Am I missing something?
http://jsfiddle.net/MMKdz/
HTML
<div class="aside-visitus">
<h2> H2 </h2>
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat</p>
<p class="aside-caption"> More information
</p>
</div>
<div class="aside-visitus">
<h2> H2 </h2>
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.</p>
<p class="aside-caption"> More information
</p>
</div>
CSS
.aside-visitus {
border:1px solid black;
margin:20px 0;
}
.aside-visitus a {
color:#4682b4;
float:right;
}
The clear and display methods don't work at all.
The most appropriate is use text-align: right propiety
http://jsfiddle.net/FelipeMartinin/MMKdz/3/
.aside-visitus a {
color:#4682b4;
text-align: right;
display: block;
}
Or you can give a display: table for the div.
You could add overflow:hidden to the parent element. This will establish a new block formatting context, thus forcing the element to contain the floated elements.
The reason this is required is because the parent element doesn't have a defined height and the child element is being floated. According to the nature of floating elements, they are essentially removed from the flow of the document; you need to reestablish the block formatting context.
jsFiddle example
.aside-visitus {
border: 1px solid black;
margin: 20px 0;
overflow: hidden;
}
Alternatively, you could use a clearfix which does the same thing. This method has more support.
I wouldn't use float. I'd add text-align:right to the .aside-caption class.
.aside-caption
{
text-align:right;
}
Fiddle: http://jsfiddle.net/MMKdz/2/
I am trying to set a nested div on the top right of its parent div and text to wrap around the nested div.
I really should understand how position, float and display work together.
Here is my sample:
CSS
.parentDiv {
width:295px;
border:1px solid black;
}
.parentDiv .childDiv1 {
width:36px;
border:1px solid black;
float:left;
}
.parentDiv .childDiv2 {
width:210px;
border:1px solid black;
float:left;
}
.parentDiv .childDiv3 {
width:44px;
right:0px;
top:0px;
border:1px solid gray;
position:relative;
float:right;
}
HTML
<div class="parentDiv">
<div class="childDiv1">
<img alt="adfasf" src="../img/image.gif">
</div>
<div class="childDiv2">Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.
<div class="childDiv3"> <span>search here</span>
</div>
</div>
</div>
Live jsfiddle
Like this: jsFiddle. Make the child div appear first as a child of childDiv2 and keep the CSS as-is.
Move it inside .childDiv2
Demo here
CSS (no change):
.parentDiv { width:295px;border:1px solid black; }
.parentDiv .childDiv1 { width:36px;border:1px solid black;float:left; }
.parentDiv .childDiv2 { width:210px;border:1px solid black;float:left; }
.parentDiv .childDiv3 { width:44px;right:0px;top:0px;border:1px solid gray; position:relative; float:right; }
HTML
<div class="parentDiv">
<div class="childDiv2">
<div class="childDiv1">
<img alt="adfasf" src="../img/image.gif">
</div>
Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.
<div class="childDiv3">
<span>search here</span>
</div>
</div>
</div>
Here is a simplified version:
<div class="childDiv2">
<div class="childDiv3">
<span>search here</span>
</div>
Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.</div>
CSS:
.childDiv2 { width:210px;border:1px solid black;}
.childDiv3 { width:44px;right:0px;top:0px;border:1px solid gray;float:right }
Here's my jsFiddle solution
In addition to the fix, I removed the unnecessary CSS.
The reason for this issue is parsing order. HTML is parsed left-to-right, top-to-bottom. When you have element-A declared after element-B, element-A will naturally be parsed after element-B.
As others have noted, all that needed to be done was to move the paragraph of text so that it's declared after childDiv3. This will allow childDiv3 to reside on the first line of childDiv2 and float itself normally.
Additionally, I added a margin to childDiv1 and some padding to parentDiv to space things out a bit. Feel free to strip out or modify properties as you wish. I also added a .clear element before the closing tag of parentDiv so that it would properly wrap around its floated child elements, as you may have intended it to.