如何将完整的行悬停在CSS中? [英] How to hover the complete row in css?

查看:96
本文介绍了如何将完整的行悬停在CSS中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个截图,如下所示,该截图已用HTML,CSS和JS复制.

I have a screenshot as shown below which I have replicated in HTML, CSS and JS.

我为上述屏幕截图创建了小提琴. 上面的屏幕截图位于小提琴的最右侧.单击三个点后,将显示下拉菜单.

I have created the fiddle for the above screenshot. The above screen-shot portion is at the extreme right in the fiddle. On clicking three dots, the drop-down menu appears.


我用来创建下拉菜单的HTML和CSS代码是:


The HTML and CSS codes which I have used in order to create the drop-down is:

HTML :

<div class="nav-top-searchbar">
    <form>
        <span class="fa fa-search searchicon fa-lg" aria-hidden="true"></span>
        <input type="text" name="search">
        <div style="">
            <img tabindex="1" src="https://s9.postimg.org/d6s4xvykv/Ellipsis.png" id="ellipsis">
            <div class="dropdown">
                <li><a href="#">View Status</a><i class="fa fa-angle-down" aria-hidden="true"></i></li>
                <li><a href="#">Release Bills</a></li>
                <li><a href="#">Add Attendee</a></li>
                <li><a href="#">Export as</a></li>
                <li><a href="#">View in Google Sheets</a></li>
                <li><a href="#">Send Notifications</a></li>
            </div>
        </div>


    </form>
</div>

CSS:

// General CSS
.nav-top-searchbar {
    position: relative;
}

#ellipsis {
    top: 12px;
    position: absolute;
    right: 43px;
    cursor: pointer;
}

#ellipsis:focus {
    outline: none;
}

#ellipsis:focus+.dropdown {
    display: block;
}

input[type=text] {
    width: 100%;
    background: #10314c;
}

.dropdown {
    background-color: #FFFFFF;
    display: none;
    padding-left: 2%;
    position: absolute;
    /* height: 150px; */
    right: 0;
    width: 200px;
    z-index: 10;
    list-style-type: none;
    padding-top: 25px;
    padding-bottom: 25px;
    box-shadow: 0 0 15px #888;
    top: 2px;
}

.searchicon {
    float: left;
    margin-top: -20px;
    position: relative;
    top: 26px;
    left: 8px;
    color: white;
    border: 1px solid #FFFFFF;
    z-index: 2;
    padding: 3px;
}

.dropdown a {
    color: #676767;
    font-weight: bold;
    font-size: 14px;
}

.dropdown li:hover {
    background-color: #EDEDED;
}



问题陈述:



Problem Statement:

在我的小提琴中,悬停不会覆盖整行.它仅覆盖该行的80%.我想知道我需要在上述CSS代码中进行哪些更改,以使悬停覆盖整个行.

In my fiddle, the hover doesn't cover the entire row. It only covers 80% of the row. I am wondering what changes do I need to make in the above CSS codes so that the hover covers the entire row.

推荐答案

您在下拉式容器上填充了

You have padding on your dropdown container:

.dropdown{
    padding-left: 2%;
}

子列表项无法使用此空间.将填充物放到列表项上:

This space is unusable by the child list items. Put the padding on the list items instead:

.dropdown li{
    padding-left: 2%;
}

https://jsfiddle.net/nc2djn5p/94/

这篇关于如何将完整的行悬停在CSS中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆