Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
190 views
in Technique[技术] by (71.8m points)

html - How to display bottom border of div's table

I am trying to do a Tic Tac Toe in JS, but at first I would like to create prototype of a board.

User will provide dimensions of a board (5x5 3x3 ect)

The problem is that I cannot set bottom border of the last #row

Could you please let me know what I am doing wrong here? Thank you

#mainContainer {
    height: auto;
    width: auto;
    border: solid black;
    border-right-style: none;
    border-top-style: none;
    border-bottom-style: none;
}

#mainContainer>div:last-child {
    border: solid black;
    border-right-style: none;
    border-top-style: none;
    border-left-style: none;

}

div.row {
    display: table-row;
    width: auto;
    height: auto;
}

div.column {

    display: table-column;
    width: auto;
    height: auto;
    vertical-align: middle;
    padding: 20px;
    text-align: center;
    font-size: 50px;
    float: left;
    margin: 0px;
    border: solid black;
    border-left-style: none;
    border-bottom-style: none;
}
<div id="mainContainer">
    <div class="row">
        <div class="column">1 1</div>
        <div class="column">1 2</div>
        <div class="column">1 3</div>
    </div>
    <div style="clear: both;"></div>
    <div class="row">
        <div class="column">2 1</div>
        <div class="column">2 2</div>
        <div class="column">2 3</div>
    </div>
    <div style="clear: both;"></div>
    <div class="row">
        <div class="column">3 1</div>
        <div class="column">3 2</div>
        <div class="column">3 3</div>
    </div>

</div>
question from:https://stackoverflow.com/questions/65925085/how-to-display-bottom-border-of-divs-table

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You've set border-bottom-style: none for all .column. Set solid for the last row.

#mainContainer {
    height: auto;
    width: auto;
    border: solid black;
    border-right-style: none;
    border-top-style: none;
    border-bottom-style: none;
}

#mainContainer>div:last-child {
    border: solid black;
    border-right-style: none;
    border-top-style: none;
    border-left-style: none;

}

div.row {
    display: table-row;
    width: auto;
    height: auto;
}

div.column {

    display: table-column;
    width: auto;
    height: auto;
    vertical-align: middle;
    padding: 20px;
    text-align: center;
    font-size: 50px;
    float: left;
    margin: 0px;
    border: solid black;
    border-left-style: none;
    border-bottom-style: none;
}

.row:last-child .column {border-bottom-style: solid}
<div id="mainContainer">
    <div class="row">
        <div class="column">1 1</div>
        <div class="column">1 2</div>
        <div class="column">1 3</div>
    </div>
    <div style="clear: both;"></div>
    <div class="row">
        <div class="column">2 1</div>
        <div class="column">2 2</div>
        <div class="column">2 3</div>
    </div>
    <div style="clear: both;"></div>
    <div class="row">
        <div class="column">3 1</div>
        <div class="column">3 2</div>
        <div class="column">3 3</div>
    </div>

</div>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...