Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS How to align buttons horizontally?

  • This topic is empty.
Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
    Posts
  • #184936
    web_editor
    Participant

    How to align buttons horizontally? I try to put this stuff, but its not working

    overflow: hidden;
        margin-left:auto;
        margin-right:0px;

    Here’s the link of full css

    Here’s the link of the site where I have two buttons, please see the Calculator link

    #184937
    Paulie_D
    Member

    It’s not clear what you mean but a reduced case in Codepen would be useful.

    The buttons seem to be floated to the left so you might need to remove that.

    #184938
    web_editor
    Participant

    I remove now the float, but still the button is not display in horizontally

    #184939
    Paulie_D
    Member

    I remove now the float, but still the button is not display in horizontally

    With the float removed the margin:0 auto should now centre them

    #184940
    web_editor
    Participant

    Yes, it center already, but not horizontally align

    #184941
    Paulie_D
    Member

    not horizontally align

    Perhaps you could explain what this means…align to what?

    Do you mean next to each other?

    #184998
    web_editor
    Participant

    display: inline-block;

    I already have that, but still its not working

    #185007
    __
    Participant

    @web_editor, Paulie_D and Jerba have both asked you to explain what you mean by “horizontally align.” I would have assumed you were referring to the differences between:

    <-- left  <-->  center  <-->  right  -->
    <----   j  u  s  t  i  f  i  e  d  ---->
    

    …but your responses seem to indicate you’re talking about something else. Please explain in more detail, so we know what problem you are trying to solve.

    #185011
    web_editor
    Participant

    What I mean in horizontally align is I want the two button display in one line only like this

    #185015
    chrisburton
    Participant

    Ah. You want them horizontally inline.

    .calbutton, .resetbutton {display: inline-block;}
    
    #185017
    __
    Participant

    Yes, but problem is the buttons are each wrapped in separate divs. They need to be adjacent (as they are in your codepen example) for this to work.

    <!-- effortless -->
    <input type=reset><input type=submit>
    
    <!-- difficult, impractical -->
    <div>
        <input type=reset>
        <span></span>
        <div class=clearer></div>
    </div>
    <div>
        <input type=submit>
        <span></span>
        <div class=clearer></div>
    </div>
    

    Do you have control of the markup? It looks like it is programatically generated (e.g., by web publishing software or a plugin of some sort).

    #185018
    web_editor
    Participant

    I have that tag already, but the button is still not in-line :\

    #185019
    __
    Participant

    I edited my post above to clarify what I meant. Please have a look.

    Again, do you have control of the markup? Can you make changes? You don’t need to add anything. You need to get rid of stuff and actually put the buttons next to each other.

    As it is, you have a lot of markup that is specifically trying to prevent you from doing this.

    #185021
    web_editor
    Participant

    Yes I have the control in markup. I have this

Viewing 14 posts - 1 through 14 (of 14 total)
  • The forum ‘CSS’ is closed to new topics and replies.