Aligning buttons in CSS/HTML in one line horizontally w/ text?

后端 未结 2 1215
情话喂你
情话喂你 2021-01-19 06:01

I would like to know how could I align my buttons horizontally? On top of that I want to add text to those buttons. This is what I currently have.

HTML body part:

相关标签:
2条回答
  • 2021-01-19 06:37

    Ok you need to exchange the img and the p with this:

    <button style="background: url('./images/button_left.png'); width: 100px; height: 50px; border: 0;">Button one</button>
    

    http://jsfiddle.net/6duRf/

    0 讨论(0)
  • 2021-01-19 06:44

    tables should not be used for layout. I think the best approach would be to use floated links like this:

    <div class="tile_div">
        <a href="#">Button one</a>
        <a href="#">Button two</a>
        <a href="#" class="last">Button three</a>
        <div class="clear"></div>
    </div>
    

    CSS:

    .tile_div a {
        display: block;
        float: left;
        height: 50px;
        width: 100px;
        margin-right: 5px;
        background-image: url(./images/button_left.png);
        text-align: center;
        line-height: 50px;
        text-decoration: none;
    }
    
    .title_div a.last {
        margin-right: 0;
    }
    
    .clear {
        clear: both;
    }
    

    JSFiddle

    0 讨论(0)
提交回复
热议问题