How to select 4 borders of a table cell with crash collapse

I want to highlight the borders of cells that have a class active.

The problem is that the table property is border-collapseset to a value collapsethat hides the borders of the cells topand left(with the exception of cells with the left and top rows). This causes a problem when the illumination class ( active) does not highlight the boundaries topand left.

You can find the problem here .

HTML

<div style="padding: 10px">
    <table>
        <tr>
            <td>1.1</td>
            <td>1.2</td>
            <td>1.3</td>
            <td>1.4</td>
            <td>1.5</td>
        </tr>
        <tr>
            <td>2.1</td>
            <td>2.2</td>
            <td class="active">2.3</td>
            <td>2.4</td>
            <td>2.5</td>
        </tr>
        <tr>
            <td>3.1</td>
            <td>3.2</td>
            <td>3.3</td>
            <td>3.4</td>
            <td>3.5</td>
        </tr>
        <tr>
            <td>4.1</td>
            <td>4.2</td>
            <td>4.3</td>
            <td>4.4</td>
            <td>4.5</td>
        </tr>
        <tr>
            <td>5.1</td>
            <td>5.2</td>
            <td>5.3</td>
            <td>5.4</td>
            <td>5.5</td>
        </tr>
    </table>
</div>

CSS

table {
    table-layout: fixed;
    border-spacing: 0;
    border-collapse: collapse;
}

td {
    border: 1px solid lightgrey;
    height: 60px;
    width: 60px;
    text-align: center;
    vertical-align: middle;
}

td.active {
    border: 1px solid blue;
}

td.brdr-b-hide {
    border-bottom: none;
}
td.brdr-r-hide {
    border-right: none;
}

Javascript

$('table').on('click', 'td', function(e){
        var target = $(e.currentTarget);

        if(e.ctrlKey && target.hasClass('active')){
            target.removeClass('active');
        } else if(e.ctrlKey) {
            target.addClass('active');
        } else {
            $('table td.active').removeClass('active');
            target.addClass('active');
        }
    });

One solution I'm working on is to hide the border-rightcell on the left side of the cell activeand the border-bottomcell at the top.

, active . prev / / .

.

, ?

+3
2

border-style: double. :

td.active {
    border: 1px solid blue;
    border-style:double;
}

http://jsfiddle.net/2ahfP/18/

+10

:

td.active {
    outline: 1px solid blue;
}

, . border-collapse .

+1

Source: https://habr.com/ru/post/1681632/


All Articles