How to highlight and detect mouse clicks on a css grid row?












-2















I'm trying to create a menu which I'm laying out using CSS grid. The problem that I'm having is figuring out how I can make the menu interactive when the mouse is hovering over each menu item.



I would like to be able to highlight the entire row when the mouse is over any of the menu items in the row. I can highlight each individual grid cell by adding a :hover css rule, but I don't know how to highlight the entire grid row.



The second part is then detecting when a row is being clicked. Again, I can add an onClick event handler to each cell but that doesn't seem ideal, as users could accidentally click in the gap between grid cells. I was thinking that if I can figure out how to highlight the entire row, then i could add the click handler to this row highlighter and that would solve the gap click problem.



I have created a codepen example that demonstrates how the menu is currently constructed: https://codepen.io/marekKnows_com/pen/RqMgGw



HTML:



<div class="myGrid">
<div class="anchor" id="item1">
<i class="image material-icons">folder_open</i>
</div>
<span class="text">Open...</span>
<span class="shortcut">Ctrl+O</span>

<div class="anchor" id="item2">
<i class="image material-icons">save</i>
</div>
<span class="text">Save...</span>
<span class="shortcut">Ctrl+S</span>

<div class="anchor" id="item3"></div>
<span class="text">Action</span>

<div class="separator"></div>

<div class="anchor" id="item4"></div>
<span class="text">Exit</span>
<span class="shortcut">Ctrl+X</span>
</div>


CSS:



.myGrid {
border: 1px solid black;
display: grid;
grid-template-columns: 20px auto auto;
grid-gap: 2px 6px;
align-items: center;
justify-items: start;
padding: 10px;
box-sizing: border-box;
}
.image {
width: 24px;
}
.text {
height: 28px;
line-height: 28px
}
.shortcut {
justify-self: end;
padding: 0 5px;
height: 28px;
line-height: 28px
}
.separator {
grid-column: 1 / span 3;
width: 100%;
height: 3px;
border-bottom: 1px solid lightgray;
}









share|improve this question























  • Easier and faster with flex and changed structure, also more appropriate.

    – VXp
    Nov 22 '18 at 20:06













  • just add #item1:hover > .mygrid{ border:1px solid red }

    – Himanshu Ahuja
    Nov 22 '18 at 20:13













  • I can't use flex because that doesn't guarantee that all the images, text and shortcuts will line up in nice columns. That is why I went with a grid and not a flex layout.

    – MarekKnows.com
    Nov 22 '18 at 20:51











  • #item1:hover > .mygrid{ border:1px solid red } doesn't work. I pasted into my codepen example and I don't see anything happen

    – MarekKnows.com
    Nov 22 '18 at 20:51
















-2















I'm trying to create a menu which I'm laying out using CSS grid. The problem that I'm having is figuring out how I can make the menu interactive when the mouse is hovering over each menu item.



I would like to be able to highlight the entire row when the mouse is over any of the menu items in the row. I can highlight each individual grid cell by adding a :hover css rule, but I don't know how to highlight the entire grid row.



The second part is then detecting when a row is being clicked. Again, I can add an onClick event handler to each cell but that doesn't seem ideal, as users could accidentally click in the gap between grid cells. I was thinking that if I can figure out how to highlight the entire row, then i could add the click handler to this row highlighter and that would solve the gap click problem.



I have created a codepen example that demonstrates how the menu is currently constructed: https://codepen.io/marekKnows_com/pen/RqMgGw



HTML:



<div class="myGrid">
<div class="anchor" id="item1">
<i class="image material-icons">folder_open</i>
</div>
<span class="text">Open...</span>
<span class="shortcut">Ctrl+O</span>

<div class="anchor" id="item2">
<i class="image material-icons">save</i>
</div>
<span class="text">Save...</span>
<span class="shortcut">Ctrl+S</span>

<div class="anchor" id="item3"></div>
<span class="text">Action</span>

<div class="separator"></div>

<div class="anchor" id="item4"></div>
<span class="text">Exit</span>
<span class="shortcut">Ctrl+X</span>
</div>


CSS:



.myGrid {
border: 1px solid black;
display: grid;
grid-template-columns: 20px auto auto;
grid-gap: 2px 6px;
align-items: center;
justify-items: start;
padding: 10px;
box-sizing: border-box;
}
.image {
width: 24px;
}
.text {
height: 28px;
line-height: 28px
}
.shortcut {
justify-self: end;
padding: 0 5px;
height: 28px;
line-height: 28px
}
.separator {
grid-column: 1 / span 3;
width: 100%;
height: 3px;
border-bottom: 1px solid lightgray;
}









share|improve this question























  • Easier and faster with flex and changed structure, also more appropriate.

    – VXp
    Nov 22 '18 at 20:06













  • just add #item1:hover > .mygrid{ border:1px solid red }

    – Himanshu Ahuja
    Nov 22 '18 at 20:13













  • I can't use flex because that doesn't guarantee that all the images, text and shortcuts will line up in nice columns. That is why I went with a grid and not a flex layout.

    – MarekKnows.com
    Nov 22 '18 at 20:51











  • #item1:hover > .mygrid{ border:1px solid red } doesn't work. I pasted into my codepen example and I don't see anything happen

    – MarekKnows.com
    Nov 22 '18 at 20:51














-2












-2








-2


1






I'm trying to create a menu which I'm laying out using CSS grid. The problem that I'm having is figuring out how I can make the menu interactive when the mouse is hovering over each menu item.



I would like to be able to highlight the entire row when the mouse is over any of the menu items in the row. I can highlight each individual grid cell by adding a :hover css rule, but I don't know how to highlight the entire grid row.



The second part is then detecting when a row is being clicked. Again, I can add an onClick event handler to each cell but that doesn't seem ideal, as users could accidentally click in the gap between grid cells. I was thinking that if I can figure out how to highlight the entire row, then i could add the click handler to this row highlighter and that would solve the gap click problem.



I have created a codepen example that demonstrates how the menu is currently constructed: https://codepen.io/marekKnows_com/pen/RqMgGw



HTML:



<div class="myGrid">
<div class="anchor" id="item1">
<i class="image material-icons">folder_open</i>
</div>
<span class="text">Open...</span>
<span class="shortcut">Ctrl+O</span>

<div class="anchor" id="item2">
<i class="image material-icons">save</i>
</div>
<span class="text">Save...</span>
<span class="shortcut">Ctrl+S</span>

<div class="anchor" id="item3"></div>
<span class="text">Action</span>

<div class="separator"></div>

<div class="anchor" id="item4"></div>
<span class="text">Exit</span>
<span class="shortcut">Ctrl+X</span>
</div>


CSS:



.myGrid {
border: 1px solid black;
display: grid;
grid-template-columns: 20px auto auto;
grid-gap: 2px 6px;
align-items: center;
justify-items: start;
padding: 10px;
box-sizing: border-box;
}
.image {
width: 24px;
}
.text {
height: 28px;
line-height: 28px
}
.shortcut {
justify-self: end;
padding: 0 5px;
height: 28px;
line-height: 28px
}
.separator {
grid-column: 1 / span 3;
width: 100%;
height: 3px;
border-bottom: 1px solid lightgray;
}









share|improve this question














I'm trying to create a menu which I'm laying out using CSS grid. The problem that I'm having is figuring out how I can make the menu interactive when the mouse is hovering over each menu item.



I would like to be able to highlight the entire row when the mouse is over any of the menu items in the row. I can highlight each individual grid cell by adding a :hover css rule, but I don't know how to highlight the entire grid row.



The second part is then detecting when a row is being clicked. Again, I can add an onClick event handler to each cell but that doesn't seem ideal, as users could accidentally click in the gap between grid cells. I was thinking that if I can figure out how to highlight the entire row, then i could add the click handler to this row highlighter and that would solve the gap click problem.



I have created a codepen example that demonstrates how the menu is currently constructed: https://codepen.io/marekKnows_com/pen/RqMgGw



HTML:



<div class="myGrid">
<div class="anchor" id="item1">
<i class="image material-icons">folder_open</i>
</div>
<span class="text">Open...</span>
<span class="shortcut">Ctrl+O</span>

<div class="anchor" id="item2">
<i class="image material-icons">save</i>
</div>
<span class="text">Save...</span>
<span class="shortcut">Ctrl+S</span>

<div class="anchor" id="item3"></div>
<span class="text">Action</span>

<div class="separator"></div>

<div class="anchor" id="item4"></div>
<span class="text">Exit</span>
<span class="shortcut">Ctrl+X</span>
</div>


CSS:



.myGrid {
border: 1px solid black;
display: grid;
grid-template-columns: 20px auto auto;
grid-gap: 2px 6px;
align-items: center;
justify-items: start;
padding: 10px;
box-sizing: border-box;
}
.image {
width: 24px;
}
.text {
height: 28px;
line-height: 28px
}
.shortcut {
justify-self: end;
padding: 0 5px;
height: 28px;
line-height: 28px
}
.separator {
grid-column: 1 / span 3;
width: 100%;
height: 3px;
border-bottom: 1px solid lightgray;
}






javascript html css grid highlight






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 22 '18 at 20:02









MarekKnows.comMarekKnows.com

349213




349213













  • Easier and faster with flex and changed structure, also more appropriate.

    – VXp
    Nov 22 '18 at 20:06













  • just add #item1:hover > .mygrid{ border:1px solid red }

    – Himanshu Ahuja
    Nov 22 '18 at 20:13













  • I can't use flex because that doesn't guarantee that all the images, text and shortcuts will line up in nice columns. That is why I went with a grid and not a flex layout.

    – MarekKnows.com
    Nov 22 '18 at 20:51











  • #item1:hover > .mygrid{ border:1px solid red } doesn't work. I pasted into my codepen example and I don't see anything happen

    – MarekKnows.com
    Nov 22 '18 at 20:51



















  • Easier and faster with flex and changed structure, also more appropriate.

    – VXp
    Nov 22 '18 at 20:06













  • just add #item1:hover > .mygrid{ border:1px solid red }

    – Himanshu Ahuja
    Nov 22 '18 at 20:13













  • I can't use flex because that doesn't guarantee that all the images, text and shortcuts will line up in nice columns. That is why I went with a grid and not a flex layout.

    – MarekKnows.com
    Nov 22 '18 at 20:51











  • #item1:hover > .mygrid{ border:1px solid red } doesn't work. I pasted into my codepen example and I don't see anything happen

    – MarekKnows.com
    Nov 22 '18 at 20:51

















Easier and faster with flex and changed structure, also more appropriate.

– VXp
Nov 22 '18 at 20:06







Easier and faster with flex and changed structure, also more appropriate.

– VXp
Nov 22 '18 at 20:06















just add #item1:hover > .mygrid{ border:1px solid red }

– Himanshu Ahuja
Nov 22 '18 at 20:13







just add #item1:hover > .mygrid{ border:1px solid red }

– Himanshu Ahuja
Nov 22 '18 at 20:13















I can't use flex because that doesn't guarantee that all the images, text and shortcuts will line up in nice columns. That is why I went with a grid and not a flex layout.

– MarekKnows.com
Nov 22 '18 at 20:51





I can't use flex because that doesn't guarantee that all the images, text and shortcuts will line up in nice columns. That is why I went with a grid and not a flex layout.

– MarekKnows.com
Nov 22 '18 at 20:51













#item1:hover > .mygrid{ border:1px solid red } doesn't work. I pasted into my codepen example and I don't see anything happen

– MarekKnows.com
Nov 22 '18 at 20:51





#item1:hover > .mygrid{ border:1px solid red } doesn't work. I pasted into my codepen example and I don't see anything happen

– MarekKnows.com
Nov 22 '18 at 20:51












3 Answers
3






active

oldest

votes


















0














I finally got it to work. What I ended up doing was making the anchor element have position relative. Then I added a new div with position absolute under the anchor element. From within JavaScript I can size the new element to be the full width of the grid and using z-index I can position it relative to the other elements in the row accordingly.






share|improve this answer































    -1














    Firstly, you might want to change your html so the .anchor elements are wrapping each item.



    <div class="myGrid">
    <div class="anchor" id="item1">
    <i class="image material-icons">folder_open</i>
    <span class="text">Open...</span>
    <span class="shortcut">Ctrl+O</span>
    </div>
    <div class="anchor" id="item2">
    <i class="image material-icons">save</i>
    <span class="text">Save...</span>
    <span class="shortcut">Ctrl+S</span>
    </div>
    <div class="anchor" id="item3">
    <span class="text">Action</span>
    </div>
    <div class="separator"></div>
    <div class="anchor" id="item4">
    <span class="text">Exit</span>
    <span class="shortcut">Ctrl+X</span>
    </div>
    </div>


    And then use flex to align the contents of each item



    .myGrid {
    border: 1px solid black;
    padding: 10px;
    box-sizing: border-box;
    }

    .anchor {
    display: flex;
    justify-content: flex-start;
    }

    /* Hover for each anchor */
    .anchor:hover {
    background: red;
    }

    .image {
    width: 24px;
    }

    .text {
    height: 28px;
    line-height: 28px
    }

    .shortcut {
    margin-left: auto; /* push the shortcut to the right */
    padding: 0 5px;
    height: 28px;
    line-height: 28px
    }

    .separator {
    grid-column: 1 / span 3;
    width: 100%;
    height: 3px;
    border-bottom: 1px solid lightgray;
    }


    https://codepen.io/anon/pen/xQWLaE






    share|improve this answer
























    • Can't use a flex layout because it doesn't guarantee that all the images, text and shortcuts will line up in nice columns. That is why i'm using a grid instead. Note in your example, Action and Exit are not properly aligned anymore.

      – MarekKnows.com
      Nov 22 '18 at 20:54



















    -1














           .anchor:hover > 
    .mygrid
    { background:red }



    check this if it works on hovering item1 it will change the border color(from black to red as highlighting)







    share|improve this answer


























    • #item1:hover > .mygrid{ border:1px solid red } doesn't work. I pasted into my codepen example and I don't see anything happen, could you post a working codepen example with your suggested change. Maybe I'm missing a detail

      – MarekKnows.com
      Nov 22 '18 at 20:52













    • did you hover on item1

      – Himanshu Ahuja
      Nov 22 '18 at 20:54











    • Yes, see here. Hovering over any of the items doesn't display anything in red. codepen.io/marekKnows_com/pen/rQdGOM

      – MarekKnows.com
      Nov 22 '18 at 20:57











    • can you please check now i have edited it

      – Himanshu Ahuja
      Nov 22 '18 at 20:59











    • I don't see any edits

      – MarekKnows.com
      Nov 22 '18 at 21:14











    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53437417%2fhow-to-highlight-and-detect-mouse-clicks-on-a-css-grid-row%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    3 Answers
    3






    active

    oldest

    votes








    3 Answers
    3






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    I finally got it to work. What I ended up doing was making the anchor element have position relative. Then I added a new div with position absolute under the anchor element. From within JavaScript I can size the new element to be the full width of the grid and using z-index I can position it relative to the other elements in the row accordingly.






    share|improve this answer




























      0














      I finally got it to work. What I ended up doing was making the anchor element have position relative. Then I added a new div with position absolute under the anchor element. From within JavaScript I can size the new element to be the full width of the grid and using z-index I can position it relative to the other elements in the row accordingly.






      share|improve this answer


























        0












        0








        0







        I finally got it to work. What I ended up doing was making the anchor element have position relative. Then I added a new div with position absolute under the anchor element. From within JavaScript I can size the new element to be the full width of the grid and using z-index I can position it relative to the other elements in the row accordingly.






        share|improve this answer













        I finally got it to work. What I ended up doing was making the anchor element have position relative. Then I added a new div with position absolute under the anchor element. From within JavaScript I can size the new element to be the full width of the grid and using z-index I can position it relative to the other elements in the row accordingly.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 23 '18 at 14:03









        MarekKnows.comMarekKnows.com

        349213




        349213

























            -1














            Firstly, you might want to change your html so the .anchor elements are wrapping each item.



            <div class="myGrid">
            <div class="anchor" id="item1">
            <i class="image material-icons">folder_open</i>
            <span class="text">Open...</span>
            <span class="shortcut">Ctrl+O</span>
            </div>
            <div class="anchor" id="item2">
            <i class="image material-icons">save</i>
            <span class="text">Save...</span>
            <span class="shortcut">Ctrl+S</span>
            </div>
            <div class="anchor" id="item3">
            <span class="text">Action</span>
            </div>
            <div class="separator"></div>
            <div class="anchor" id="item4">
            <span class="text">Exit</span>
            <span class="shortcut">Ctrl+X</span>
            </div>
            </div>


            And then use flex to align the contents of each item



            .myGrid {
            border: 1px solid black;
            padding: 10px;
            box-sizing: border-box;
            }

            .anchor {
            display: flex;
            justify-content: flex-start;
            }

            /* Hover for each anchor */
            .anchor:hover {
            background: red;
            }

            .image {
            width: 24px;
            }

            .text {
            height: 28px;
            line-height: 28px
            }

            .shortcut {
            margin-left: auto; /* push the shortcut to the right */
            padding: 0 5px;
            height: 28px;
            line-height: 28px
            }

            .separator {
            grid-column: 1 / span 3;
            width: 100%;
            height: 3px;
            border-bottom: 1px solid lightgray;
            }


            https://codepen.io/anon/pen/xQWLaE






            share|improve this answer
























            • Can't use a flex layout because it doesn't guarantee that all the images, text and shortcuts will line up in nice columns. That is why i'm using a grid instead. Note in your example, Action and Exit are not properly aligned anymore.

              – MarekKnows.com
              Nov 22 '18 at 20:54
















            -1














            Firstly, you might want to change your html so the .anchor elements are wrapping each item.



            <div class="myGrid">
            <div class="anchor" id="item1">
            <i class="image material-icons">folder_open</i>
            <span class="text">Open...</span>
            <span class="shortcut">Ctrl+O</span>
            </div>
            <div class="anchor" id="item2">
            <i class="image material-icons">save</i>
            <span class="text">Save...</span>
            <span class="shortcut">Ctrl+S</span>
            </div>
            <div class="anchor" id="item3">
            <span class="text">Action</span>
            </div>
            <div class="separator"></div>
            <div class="anchor" id="item4">
            <span class="text">Exit</span>
            <span class="shortcut">Ctrl+X</span>
            </div>
            </div>


            And then use flex to align the contents of each item



            .myGrid {
            border: 1px solid black;
            padding: 10px;
            box-sizing: border-box;
            }

            .anchor {
            display: flex;
            justify-content: flex-start;
            }

            /* Hover for each anchor */
            .anchor:hover {
            background: red;
            }

            .image {
            width: 24px;
            }

            .text {
            height: 28px;
            line-height: 28px
            }

            .shortcut {
            margin-left: auto; /* push the shortcut to the right */
            padding: 0 5px;
            height: 28px;
            line-height: 28px
            }

            .separator {
            grid-column: 1 / span 3;
            width: 100%;
            height: 3px;
            border-bottom: 1px solid lightgray;
            }


            https://codepen.io/anon/pen/xQWLaE






            share|improve this answer
























            • Can't use a flex layout because it doesn't guarantee that all the images, text and shortcuts will line up in nice columns. That is why i'm using a grid instead. Note in your example, Action and Exit are not properly aligned anymore.

              – MarekKnows.com
              Nov 22 '18 at 20:54














            -1












            -1








            -1







            Firstly, you might want to change your html so the .anchor elements are wrapping each item.



            <div class="myGrid">
            <div class="anchor" id="item1">
            <i class="image material-icons">folder_open</i>
            <span class="text">Open...</span>
            <span class="shortcut">Ctrl+O</span>
            </div>
            <div class="anchor" id="item2">
            <i class="image material-icons">save</i>
            <span class="text">Save...</span>
            <span class="shortcut">Ctrl+S</span>
            </div>
            <div class="anchor" id="item3">
            <span class="text">Action</span>
            </div>
            <div class="separator"></div>
            <div class="anchor" id="item4">
            <span class="text">Exit</span>
            <span class="shortcut">Ctrl+X</span>
            </div>
            </div>


            And then use flex to align the contents of each item



            .myGrid {
            border: 1px solid black;
            padding: 10px;
            box-sizing: border-box;
            }

            .anchor {
            display: flex;
            justify-content: flex-start;
            }

            /* Hover for each anchor */
            .anchor:hover {
            background: red;
            }

            .image {
            width: 24px;
            }

            .text {
            height: 28px;
            line-height: 28px
            }

            .shortcut {
            margin-left: auto; /* push the shortcut to the right */
            padding: 0 5px;
            height: 28px;
            line-height: 28px
            }

            .separator {
            grid-column: 1 / span 3;
            width: 100%;
            height: 3px;
            border-bottom: 1px solid lightgray;
            }


            https://codepen.io/anon/pen/xQWLaE






            share|improve this answer













            Firstly, you might want to change your html so the .anchor elements are wrapping each item.



            <div class="myGrid">
            <div class="anchor" id="item1">
            <i class="image material-icons">folder_open</i>
            <span class="text">Open...</span>
            <span class="shortcut">Ctrl+O</span>
            </div>
            <div class="anchor" id="item2">
            <i class="image material-icons">save</i>
            <span class="text">Save...</span>
            <span class="shortcut">Ctrl+S</span>
            </div>
            <div class="anchor" id="item3">
            <span class="text">Action</span>
            </div>
            <div class="separator"></div>
            <div class="anchor" id="item4">
            <span class="text">Exit</span>
            <span class="shortcut">Ctrl+X</span>
            </div>
            </div>


            And then use flex to align the contents of each item



            .myGrid {
            border: 1px solid black;
            padding: 10px;
            box-sizing: border-box;
            }

            .anchor {
            display: flex;
            justify-content: flex-start;
            }

            /* Hover for each anchor */
            .anchor:hover {
            background: red;
            }

            .image {
            width: 24px;
            }

            .text {
            height: 28px;
            line-height: 28px
            }

            .shortcut {
            margin-left: auto; /* push the shortcut to the right */
            padding: 0 5px;
            height: 28px;
            line-height: 28px
            }

            .separator {
            grid-column: 1 / span 3;
            width: 100%;
            height: 3px;
            border-bottom: 1px solid lightgray;
            }


            https://codepen.io/anon/pen/xQWLaE







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Nov 22 '18 at 20:31









            kabadesukabadesu

            592




            592













            • Can't use a flex layout because it doesn't guarantee that all the images, text and shortcuts will line up in nice columns. That is why i'm using a grid instead. Note in your example, Action and Exit are not properly aligned anymore.

              – MarekKnows.com
              Nov 22 '18 at 20:54



















            • Can't use a flex layout because it doesn't guarantee that all the images, text and shortcuts will line up in nice columns. That is why i'm using a grid instead. Note in your example, Action and Exit are not properly aligned anymore.

              – MarekKnows.com
              Nov 22 '18 at 20:54

















            Can't use a flex layout because it doesn't guarantee that all the images, text and shortcuts will line up in nice columns. That is why i'm using a grid instead. Note in your example, Action and Exit are not properly aligned anymore.

            – MarekKnows.com
            Nov 22 '18 at 20:54





            Can't use a flex layout because it doesn't guarantee that all the images, text and shortcuts will line up in nice columns. That is why i'm using a grid instead. Note in your example, Action and Exit are not properly aligned anymore.

            – MarekKnows.com
            Nov 22 '18 at 20:54











            -1














                   .anchor:hover > 
            .mygrid
            { background:red }



            check this if it works on hovering item1 it will change the border color(from black to red as highlighting)







            share|improve this answer


























            • #item1:hover > .mygrid{ border:1px solid red } doesn't work. I pasted into my codepen example and I don't see anything happen, could you post a working codepen example with your suggested change. Maybe I'm missing a detail

              – MarekKnows.com
              Nov 22 '18 at 20:52













            • did you hover on item1

              – Himanshu Ahuja
              Nov 22 '18 at 20:54











            • Yes, see here. Hovering over any of the items doesn't display anything in red. codepen.io/marekKnows_com/pen/rQdGOM

              – MarekKnows.com
              Nov 22 '18 at 20:57











            • can you please check now i have edited it

              – Himanshu Ahuja
              Nov 22 '18 at 20:59











            • I don't see any edits

              – MarekKnows.com
              Nov 22 '18 at 21:14
















            -1














                   .anchor:hover > 
            .mygrid
            { background:red }



            check this if it works on hovering item1 it will change the border color(from black to red as highlighting)







            share|improve this answer


























            • #item1:hover > .mygrid{ border:1px solid red } doesn't work. I pasted into my codepen example and I don't see anything happen, could you post a working codepen example with your suggested change. Maybe I'm missing a detail

              – MarekKnows.com
              Nov 22 '18 at 20:52













            • did you hover on item1

              – Himanshu Ahuja
              Nov 22 '18 at 20:54











            • Yes, see here. Hovering over any of the items doesn't display anything in red. codepen.io/marekKnows_com/pen/rQdGOM

              – MarekKnows.com
              Nov 22 '18 at 20:57











            • can you please check now i have edited it

              – Himanshu Ahuja
              Nov 22 '18 at 20:59











            • I don't see any edits

              – MarekKnows.com
              Nov 22 '18 at 21:14














            -1












            -1








            -1







                   .anchor:hover > 
            .mygrid
            { background:red }



            check this if it works on hovering item1 it will change the border color(from black to red as highlighting)







            share|improve this answer















                   .anchor:hover > 
            .mygrid
            { background:red }



            check this if it works on hovering item1 it will change the border color(from black to red as highlighting)








            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Nov 22 '18 at 20:57

























            answered Nov 22 '18 at 20:16









            Himanshu AhujaHimanshu Ahuja

            9322218




            9322218













            • #item1:hover > .mygrid{ border:1px solid red } doesn't work. I pasted into my codepen example and I don't see anything happen, could you post a working codepen example with your suggested change. Maybe I'm missing a detail

              – MarekKnows.com
              Nov 22 '18 at 20:52













            • did you hover on item1

              – Himanshu Ahuja
              Nov 22 '18 at 20:54











            • Yes, see here. Hovering over any of the items doesn't display anything in red. codepen.io/marekKnows_com/pen/rQdGOM

              – MarekKnows.com
              Nov 22 '18 at 20:57











            • can you please check now i have edited it

              – Himanshu Ahuja
              Nov 22 '18 at 20:59











            • I don't see any edits

              – MarekKnows.com
              Nov 22 '18 at 21:14



















            • #item1:hover > .mygrid{ border:1px solid red } doesn't work. I pasted into my codepen example and I don't see anything happen, could you post a working codepen example with your suggested change. Maybe I'm missing a detail

              – MarekKnows.com
              Nov 22 '18 at 20:52













            • did you hover on item1

              – Himanshu Ahuja
              Nov 22 '18 at 20:54











            • Yes, see here. Hovering over any of the items doesn't display anything in red. codepen.io/marekKnows_com/pen/rQdGOM

              – MarekKnows.com
              Nov 22 '18 at 20:57











            • can you please check now i have edited it

              – Himanshu Ahuja
              Nov 22 '18 at 20:59











            • I don't see any edits

              – MarekKnows.com
              Nov 22 '18 at 21:14

















            #item1:hover > .mygrid{ border:1px solid red } doesn't work. I pasted into my codepen example and I don't see anything happen, could you post a working codepen example with your suggested change. Maybe I'm missing a detail

            – MarekKnows.com
            Nov 22 '18 at 20:52







            #item1:hover > .mygrid{ border:1px solid red } doesn't work. I pasted into my codepen example and I don't see anything happen, could you post a working codepen example with your suggested change. Maybe I'm missing a detail

            – MarekKnows.com
            Nov 22 '18 at 20:52















            did you hover on item1

            – Himanshu Ahuja
            Nov 22 '18 at 20:54





            did you hover on item1

            – Himanshu Ahuja
            Nov 22 '18 at 20:54













            Yes, see here. Hovering over any of the items doesn't display anything in red. codepen.io/marekKnows_com/pen/rQdGOM

            – MarekKnows.com
            Nov 22 '18 at 20:57





            Yes, see here. Hovering over any of the items doesn't display anything in red. codepen.io/marekKnows_com/pen/rQdGOM

            – MarekKnows.com
            Nov 22 '18 at 20:57













            can you please check now i have edited it

            – Himanshu Ahuja
            Nov 22 '18 at 20:59





            can you please check now i have edited it

            – Himanshu Ahuja
            Nov 22 '18 at 20:59













            I don't see any edits

            – MarekKnows.com
            Nov 22 '18 at 21:14





            I don't see any edits

            – MarekKnows.com
            Nov 22 '18 at 21:14


















            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53437417%2fhow-to-highlight-and-detect-mouse-clicks-on-a-css-grid-row%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            這個網誌中的熱門文章

            Academy of Television Arts & Sciences

            L'Équipe

            1995 France bombings