2

I want to display the button in div tag on right side.I use the code which I used to display the div content on right side.Now I have a problem that my div tag display on left side. I want to display login div tag on right side. I created a layout.I want to display login div tag where I marked as red and named it btn div.I marked current display of div tag in blue color. enter image description here

CSS

.login {
    margin:0;
    padding:0px 0px 0 0;
    text-align:right;
    float:right;
    width:40%;
}

HTML

<div class="header">
    <div class="ribbon"></div>
    <div class="logo"></div>
    <div class="login">//btn</div>
</div>

http://jsfiddle.net/mount/q4gxv7y2/

user3386779
  • 6,883
  • 20
  • 66
  • 134
  • try on the header `position: relative` and the div login/btn `position:absolute; bottom: 0; right: 0;` – Tune389 Feb 26 '15 at 07:30
  • No needs to make hard stats: position: relative/ position:absolute; bottom: 0; right: 0; is what you have to do:) – Gaël Barbin Feb 26 '15 at 07:37
  • You need to try more CSS option before you ask. Study here http://www.w3schools.com/css/default.asp – Mardzis Feb 26 '15 at 07:44

5 Answers5

3

You can use an absolute position for your login div. For that, you also have to set the header position as relative, in order to make position the login div relatively to it.

Position absolute but relative to parent

.header{
   position:relative;
  background:red;
  width:100%;
  height:100px;
  margin-bottom:300px
}
.login{
    margin:0;
    padding:0px 0px 0 0;
    text-align:right;
    width:40%;
  
  position:absolute; 
  right:0;
  bottom:0;
  background:blue;
}
  <div class="header"> 
      <div class="ribbon">
      </div>
      <div class="logo">
      </div>
      <div class="login">
          //btn 
      </div>   
  </div>
Community
  • 1
  • 1
Gaël Barbin
  • 3,769
  • 3
  • 25
  • 52
0

Something like:

.header {
    position: relative;
}

. login  {
    position: absolute;
    bottom: 0;
    right: 0;
}
Adam Michna
  • 169
  • 1
  • 7
0

Use position:absolute to achieve this.

HTML

<div class="header"> 
    <div class="ribbon">
    </div>
    <div class="logo">
    </div>
    <div class="login">
    //btn 
    </div>   
</div>

CSS

.header {
    width:100%;
    height:40px;
    outline:1px solid green;
    position:relative;   
}
.login{
    margin:0;
    padding:0px 0px 0 0;
    text-align:right;
    float:right;
    width:40%;
    outline:1px solid red;
    position:absolute;
    right:0;
    bottom:0;
}

JSFiddle demo

Side note: Keep in mind that class is only used for objects placed more than once on a page. If an object is only placed once on the page, in your case for example: header, logo, then you should use id instead of class. Biggest reason for this is because id's have a higher specificity score compared to classes. So you can give styles to all objects more controlled.

Daan
  • 2,680
  • 20
  • 39
0

html:

<div class="header"> 
    <div class="ribbon"></div>
    <div class="logo"></div>
    <div class="login">
         <input type='button' value='right click' class='right-button'>
    </div>   
</div>

css:

.login{
    margin:0;
    padding:0px 0px 0 0;
    text-align:right;
    float:right;
    width:40%;
    border: 1px red solid;
    height: 100%;
    position:relative;
}
.header{
    width: 100%;
    height: 100px;
    border: 1px green solid;
}
.right-button{
    position:absolute;
    bottom:0;
    right:0;
}

Jsfiddle Demo

rsudip90
  • 799
  • 1
  • 7
  • 24
0

You can use something like this:

CSS

.login {
    margin:0 auto;
    padding:0
    text-align:right;
    float:right;
    width:40%;
}
.ribbon{
    float:left;
}
.logo{
    float:left;
}
.header {
    width:100%;
    height:auto; // or specify the max height of content
    outline:none
    position:relative;   
}

HTML

<div class="header">
    <div class="ribbon"></div>
    <div class="logo"></div>
    <div class="login">//btn</div>
</div>