Avatar of Rohit Bajaj
Rohit Bajaj
Flag for India

asked on 

How to position two buttons side by side

HI,
I have the following html :
<div id="buttons">
        <button id="submit" disabled>Create Note</button>
        <button id="cancel">Cancel</button>
      </div>

Open in new window


currently the styling on them is  :
#buttons {
    margin-top: 18px;
    overflow: hidden;
}

#buttons :first-child {
    float: right;
}

#buttons :nth-child(2) {
    margin-right: 15px;
    float: right;
    padding: 10px 25px;
}

button  {
    background: rgba(10, 190, 81, 1);
    padding: 10px 25px;
    border: none;
    color: #fff;
    cursor: pointer;
    border-radius: 4px;
    outline: none;
}

Open in new window


And they appear like :
note-button-current.pngThe above is on chrome window
But for rendering them in a mobile i want the buttons to appear like :
button-intended.png
I was able to place them in the middle by overriding the the following rules (using the below ones):
#buttons :first-child {
    float: none;
}
#buttons :nth-child(2) {
    float: none
}
#buttons {
    text-align: center;
}

Open in new window


But as you see in the mobile screen shot.... The buttons will be having a fixed pixels distance on left and right side in the screen shot it is 35px and then the buttons are placed with note button 1.5 times larger than the cancel button

How do i make them look like the mobile ones ?
So basically i have to keep fixed 35 px off the left and right side and the rest of the space gets filled with buttons one 1.5 times larger than the other....

Thanks
Responsive WebCSSHTMLWeb Development

Avatar of undefined
Last Comment
Marco Gasi

8/22/2022 - Mon