CSS Problem - Urgent Help Required

Discussion in 'CSS' started by crazyryan, Oct 24, 2007.

  1. #1
    Basically I'm having problems aligning one piece of text to the left, and another piece of text to the right.

    My code is as follows:

    <div class="gbox">
                <div class="gboxtitle">» Members</div>
                       <span class="text">
                    Username: <input type="text" name="username" class="username" value="Username" />
                    <br /><br />
                    Password: <input type="password" name="password" class="password" value="Password" />
                    <input type="checkbox" name="checkbox" class="checkbox" /> <p class="test">Remember Me</p> <p class="test1">Sign In</p>
                    </span>
            </div>
    HTML:
    
    .gbox {
    margin-bottom: 10px;
    background: #fff;
    border: 1px solid #36b38f;
    }
    .gboxtitle {
    padding-left: 8px;
    padding-top: 8px;
    background: url("images/greeng.gif") repeat-x;
    height: 24px;
    border: 1px solid #fff;
    color: #fff;
    }
    .test {
    float: left;
    margin: 0px;
    }
    .test1 {
    float: right;
    margin: 0px;
    }
    Code (markup):
    Anyone got any ideas how I can do it, currently, the aligning works but the text doesnt stay in the box.
     
    crazyryan, Oct 24, 2007 IP
  2. Kain

    Kain Peon

    Messages:
    58
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Add a height attribute for .gbox

    I tried this and the text is inside the box now

    .gbox {
    margin-bottom: 10px;
    background: #fff;
    border: 1px solid #36b38f;
    height: 120px;
    }
     
    Kain, Oct 24, 2007 IP
  3. crazyryan

    crazyryan Well-Known Member

    Messages:
    3,087
    Likes Received:
    165
    Best Answers:
    0
    Trophy Points:
    175
    #3
    The box is going to need to expand though
     
    crazyryan, Oct 24, 2007 IP
  4. uglyboy

    uglyboy Peon

    Messages:
    1,963
    Likes Received:
    134
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Try this:

    <div class="gbox">
                <div class="gboxtitle">» Members</div>
                       <span class="text">
                    Username: <input type="text" name="username" class="username" value="Username" />
                    <br /><br />
                    Password: <input type="password" name="password" class="password" value="Password" />
                    <input type="checkbox" name="checkbox" class="checkbox" /> <p class="test">Remember Me</p> <p class="test1">Sign In</p>
                    </span>
         [B]<div style="clear:both;"></div>[/B]   
    
    </div>
    Code (markup):
     
    uglyboy, Oct 24, 2007 IP
  5. Stomme poes

    Stomme poes Peon

    Messages:
    3,195
    Likes Received:
    136
    Best Answers:
    0
    Trophy Points:
    0
    #5
    What you have is a form, and you should write is as such. This means form element, fieldset (hide with border: none; if you want), legend, all the works. Labels for each input with the same "for" as the input's id means even the blind can use your form (if that were useful for you).
    
    <div class="gbox">
        <p>&gt;&gt;Members</p>
        <form action="whatever" method="post">
          <fieldset>
          <legend><span>Pretty please would you log in?</span><legend>
    	<div>
    	<label for="username">Username:</label>
    	  <input type="text" name="username" id="username" />
    	</div>
    	<div>
    	<label for="password">Password:</label>
    	  <input type="password" name="password" id="password" />
    	</div>
    	<div>
    	<input type="checkbox" name="checkbox" id="remember" />
    	  <label for="remember" class="remember">Remember me</label>
    	<input type="submit" id="submit" value="Sign In" />
    	</div>
          </fieldset>
          </form>
        </div>
    
    Code (markup):
    CSS
    
    * {
      margin: 0;
      padding: 0;
    }
    
    .gbox {
      margin: 0 auto;
      background: #fff;
      width: 400px;
      border: 1px solid #36b38f;
    }
    
    p {
      padding-left: 8px;
      padding-top: 8px;
      background: url("images/greeng.gif") repeat-x;
      height: 24px;
      border: 1px solid #fff;
      color: #000;
    }
    
    fieldset {
      border: none;
    }
    
    legend span {
      display: block;
      color: green;
      padding-bottom: 5px;
      padding-left: 5px;
      /*whatever style*/
    }
    
    form div {
      width: 350px;
    }
    label {
      display: block;
      float: left;
      clear: left;
      width: 100px;
    }
    
    
    label.remember {
      display: inline;
      float: none;
    }
    
    form div {
      clear: left;
      float: left;
      padding: 5px;
    }
    
    #submit {
      margin-left: 100px;
    }
    
    Code (markup):
    But I dunno how you want your form to look.
    http://stommepoes.jobva.nl/Tests/form.html
    looks like sh*t in Konqueror and thus I assume Safari but I dunno why.

    Even better is to remove the <p> and move Members to inside the Legend's span and style to your liking.

    But it always need a width. So what's it expanding for? Wider content inside or to accomadate other divs?

    *Edit oh you meant the height. Should be automatic.
     
    Stomme poes, Oct 24, 2007 IP