:: HOME » CSS » CSS Boxing And Positioning
 
CSS Boxing And Positioning

To define a box we use <div> element and than we define the features of the this element to have an box.

.myBox{

background-color:#999999;

border: solid 1px black;

width:300px;

}

 

<div class="myBox">text here</div>

 

If you have more than one box, you can position them by using CSS positioning.

 

Relative positioning: if you define relative position, this element will stay exactly where it is.

 

.myBox{

background-color:#999999;

border: solid 1px black;

width:300px;

Position: relative;

}

        

Absolute positioning: if you define an element position absolute it means that other elements in document will act as that absolutely positioned element was never over there. Mostly people use this dynamic menus that when you move over the links it shows sub-menu to you.

 

.myBox{

background-color:#999999;

border: solid 1px black;

width:300px;

Position: absolute;

}

 

To position boxes we can also use floating.

 

.myBox{

background-color:#999999;

border: solid 1px black;

float:left;

width:300px;

}        

.myBox img {

float:left;

}

.myBox p {

float:right;

}

 

<div class="myBox">

<img src=tst.gif />

<p>some text</p>

</div>

 

But by using floating causes some problems. For example if you want to type any text under this box, it will be presented nead this box again. To solve such problem you should use undefined width or clear option.

 

.clear {

Clear: both;

}

 

<div class="myBox">

<img src=tst.gif />

<p>some text</p>

</div>

<div class="clear"></div>

New text

 

Also there are other solution like using JavaScript. It is up to you and you design.


CSS CSS Boxing And Positioning CSS CSS Boxing And Positioning CSS CSS Boxing And Positioning
CSS CSS Boxing And Positioning
NEW QUESTION
 
Your E-Mail Address
»
Your e-mail will never be shown!  
   
 
Question
»
Please type your question and please use [CODE] tag for your codes!  
  Add CODE Quote BOLD ITALIC Underline Align Left Align Center Align Right Add Line  
   
 
Human Check
»
Enter human check code below!  
   
 
       
 
* Your Question will be answered as soon as possible, probably within 24 hours!
CSS CSS Boxing And Positioning CSS CSS Boxing And Positioning CSS CSS Boxing And Positioning
CSS CSS Boxing And Positioning
 
Quaware Internet Solutions And Consulting - SEO Search Engine Optimization, Website development and design, eCommerce, Online Payment Systems, Shopping Cart, Affiliates Website Designer, Search Engine Optimization Expert, Ajax Developer,Developed And Designed By Mumin Celik With Using PHP, MySQL, CSS, JavaScript, Ajax And Search Engine Optimizer Sinema, Film, Ask, Tekgul, Mutluluk