Wrapper layout and div problems

Problem

Image

http://oi42.tinypic.com/51oew1.jpg

I tried this with the following CSS and HTML. It looks fine when the browser is of full width and scrambled when browser is resized. I WANT the elements to be where there and a HORIZONTAL SCROLL has to appear when the BROWSER is RESIZED. Pretty new to web programming. Text-align:center for positioning the center column would not work because, every time a new text is added in the left or right, it gets relocated and also center column element in ROW1(text) and ROW2(Button) do not appear along the same line. That is, text appears a bit right and the button a bit left. Text-align won't work here.

CSS:

  @charset "utf-8";
  /* CSS Document */

  body
  {
       background-color:#000;
  }
  .wrapper
  {
      width:70%;
      margin:0 auto;
      padding:2px;
      background-color:#fff;
   }
   .second_row
   {
      padding:2px;
      margin-top:10px;
   }

   .center_container
   {
      width:30%;
      margin:0 auto;    
   }
   .left_container
   {
      width:33%;
      float:left;
   }
   .right_container
   {
      width:33%;
      float:right;
   }
   .topelements 
   {
      margin-top:0px;
      color:#777;
      padding:2px;
   }
   .topelements a:link
   {
      color:#29a3cc;
   }
   .topelements a:active a:hover
   {
      color:#29a3cc;    
   }
   .logo
   {

      overflow:hidden;
   }

HTML code:

  <div class="wrapper"> 
    <span class="topelements float_left" >Mail us: <a href="#">admin@admin.com</a></span>
    <span class="topelements float_right">Left links <a href="#">My xyz</a></span>
    <span class="topelements center_container">Welcome to xyz ! <a href="#">Sign in</a> or <a href="#">Signup</a>.</span>
   </div>
     <div class="wrapper second_row">
       <span class="left_container">Srini</span>
       <span class="right_container">Vas</span>
           <form class="center_container">
              <input type="text" placeholder="Goooooooooooo!" />
              <input type="submit" value="Search" />
           </form>
     </div>
     <div class="wrapper">
Problem courtesy of: Srini Vas

Solution

If you want to align you object in the center, there are a couple of different ways. First of all, there is the text-align:center; which you don't need right now. There is also object-position:center; which basically does the same, but with an object. This way isn't the best, but you could add a certain percentage of padding to either side but that's not recommended. Lastly, there's alignment-adjust:central;. This may not be perfect for your situation but just try out all of these and see if they work. Good luck!

Solution courtesy of: Max

Discussion

This is just a small error I found in the CSS and I don't know if this will help too much. The div you added was not referred to as a div, but a class. For example, if you wanted to style a div in CSS, you would do this:

#divname {
CSS for div goes here...
}

On the other hand, if you wanted to add a little style to a class, you would go like this:

.classname {
CSS for class goes here...
}

If you were wondering what the difference for each is, the answer is simple. A class can define multiple objects while the divs are just limited to one object or element.

Discussion courtesy of: Max

One way that would work is to set your wrapper width to a fixed value (something in 800px for example). As long as this width was longer than all the content you are putting within that wrapper, everything should work as you want. The browser will automatically place a horizontal scroll bar when the window gets smaller than the width of the wrapper.

Discussion courtesy of: Dsel

This recipe can be found in it's original form on Stack Over Flow.