I have a main content section which has the following CSS

   #content3{

  height:auto;
  width:80%;
  margin:0 auto;
  background-color:#ffffff;
   padding-left:1%;
  padding-right:1%;
  padding-top:2%;
  text-align:left;
  font-family:Arial, Helvetica, sans-serif;
  font-size:12px;
  o

 }

I wanted extra yet separate Div block to be contained within the main element and float to the right. I could not get it to sit perfect. I am not to sure where i have went wrong . here is the code for my float element.

 #right_ad{
     float:right; width:500px; height:auto; position:inherit;
     background-color:#ffffff; margin-top:-31%; border-left-color:000; border-left-style:solid;
     border-left-width:thin; font-family:Arial, Helvetica, sans-serif; font-size:12px; text-align:justify;
     padding-left:1%; padding-right:1%; padding-top:1%;
}

I had to add a Margin-top of negative 31 for it to be aligned in the 1366 resolution of my widescreen monitor. On all other lower res screen it is pushed away to the bottom. I know i should not use negatives.

where am I going wrong?.

I need help.

  • Updated and fixed the CSS code blocks. In the future try and make sure your code is within code blocks (spaced over 4 spaces, or click the '10101' button in the menu) Ktash about 6 years ago

3 answers

Ktash 1851
2
points
This was chosen as the best answer

The HTML code here might be the bigger issue. My best guess without seeing your actual HTML code is that your div block is placed after your content block. Any content you want to float right or left needs to be placed before the content you want to float it with. So, your code should look like:

HTML

<div id="right_ad">
    ... <!-- Content you want on the right hand side. -->
</div>
<div id="content3">
   ... <!-- Main content -->
</div>

CSS

#right_ad {
    float: right;
    /* ... Styles go here ... */
}
#content3 {
    /* ... Styles go here ... */
}
Answered about 6 years ago by Ktash
0
points

Thank you very much. I never even noticed that my Div's were not in correct order. Fixed now. Thank you so much

Answered about 6 years ago by Matt Ewing
  • You're welcome. In the future, you can post this as a comment on my answer as opposed to as an answer on itself. This site has a different format then a traditional forum. Ktash about 6 years ago
  • Also, give vote as "Great Answer" when someone gives you the correct answer so they get props for their work. Xeoncross about 6 years ago
0
points

vpn firewall router

Answered about 6 years ago by Gene Sirkit