Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/86.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/35.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 仅覆盖父图像的子元素_Html_Css - Fatal编程技术网

Html 仅覆盖父图像的子元素

Html 仅覆盖父图像的子元素,html,css,Html,Css,我有一个菜单,我想有一个活动状态和悬停状态的菜单项。我的问题在这两幅图中得到了最好的说明。绿色背景色应仅覆盖图像中的深橙色区域 这是我现在的菜单: 这就是我想要的: 哪种方法是最好的削减绿色元素的底部,以获得这种效果 到目前为止,我在JSFIDLE中的代码是: CSS: 我想知道这样的事情是否能让你开始 我会再仔细研究一下,看看我们离你想要的有多近 但其概念是在:之后或:之前,或绝对定位的覆盖,并能够单击后面的框 CSS 请在你的问题中发布你的html标记和css。这是一个。。?这是背景吗。。?

我有一个菜单,我想有一个活动状态和悬停状态的菜单项。我的问题在这两幅图中得到了最好的说明。绿色背景色应仅覆盖图像中的深橙色区域

这是我现在的菜单:

这就是我想要的:

哪种方法是最好的削减绿色元素的底部,以获得这种效果

到目前为止,我在JSFIDLE中的代码是:

CSS:


我想知道这样的事情是否能让你开始

我会再仔细研究一下,看看我们离你想要的有多近

但其概念是在:之后或:之前,或绝对定位的覆盖,并能够单击后面的框

CSS


请在你的问题中发布你的html标记和css。这是一个。。?这是背景吗。。?那是梯度吗。。?我们怎么知道…?@HerrNilsson减少了css中.nav a的填充底部。这个问题现在更新了。我相信这是不可能的。。我走了这么远:但这不是你问题的答案
nav ul {
    padding: 0;
    list-style-type: none;
    position: absolute;
    right: 96px;
    top: 37px;
}

nav li {
    float: left;
}

nav a {
    text-decoration: none;
    font-weight: 400;
    font-size: .9375em;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #fff;
    padding: 54px 15px 65px 15px;
    overflow: hidden;

}

.current-menu-item a,
.current-menu-item a:hover {
    background: #79bd8f; /* Old browsers */
    background: -moz-linear-gradient(top,  #79bd8f 30%, #00a388 99%); /* FF3.6+ */
    background: -webkit-gradient(linear, left top, left bottom, color-stop(30%,#79bd8f), color-stop(99%,#00a388)); /* Chrome,Safari4+ */
    background: -webkit-linear-gradient(top,  #79bd8f 30%,#00a388 99%); /* Chrome10+,Safari5.1+ */
    background: -o-linear-gradient(top,  #79bd8f 30%,#00a388 99%); /* Opera 11.10+ */
    background: -ms-linear-gradient(top,  #79bd8f 30%,#00a388 99%); /* IE10+ */
    background: linear-gradient(to bottom,  #79bd8f 30%,#00a388 99%); /* W3C */
    filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#79bd8f', endColorstr='#00a388',GradientType=0 ); /* IE6-9 */

}

nav a:hover {
    background: #6b1600;
    background: rgba(107, 22, 0, 0.2);
}
.selector {
    width: 295px;
    height: 100px;
    overflow: hidden;
    background-color: transparent;
    position: relative;
}
.button1 {
    float: left;
    width: 32%;
    height: 100%;
    border: 1px solid white;
    background-color: blue;
}
.selector:after {
    content: '';
    width: 300px;
    height: 30px;
    position: absolute;
    top: 85px;
    left: 0px;
    transform: rotate(-3deg);
    background-color: red;
}