- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
所以我正在尝试制作一个蒙版 Logo ,其中带阴影的部分实际上是其背后内容的透明窗口。
我想我必须用 SVG 和 Masking 来解决这个问题,但我的尝试并没有像这里看到的那样顺利:
@charset "utf-8";
*{margin:0;padding:0}
body{
width:100%;
min-height:100%;
background-color:#eee;
color:#eee;
}
/*Header
-------------*/
header{
position:fixed;
top:0;
width:100%;
height:20%;
height:auto;
z-index:999;
}
#logo:before{
width:10%;
height:15vw;
display:block;
content:"";
background:#fff;
float:left;
}
#logo:after{
width:80%;
height:15vw;
display:inline-block;
content:"";
background:#fff;
}
#logo img{
float:left;
width:10%;
}
/*Content
-------------*/
main{
position:relative;
margin:auto;
width:100%;
height:200%;
background:#2d917f
}
/*Links
-------------*/
a,a:visited{
color:#eee;
text-decoration:none;
-webkit-transition:all .2s ease;
-moz-transition:all .2s ease;
-o-transition:all .2s ease;
transition:all .2s ease;
}
a:active, a:hover{
color:#fff;
border-bottom:1px solid #fff
}
/*Scrollbar
-------------*/
::-webkit-scrollbar{width:12px;height:12px;background-color:#1A1A1A}
::-webkit-scrollbar-corner{background-color:#0e0e0e}
::-webkit-scrollbar-track{background-color:#121212}
::-webkit-scrollbar-thumb{background:#2d917f}
::-webkit-scrollbar:horizontal{height:12px}
/*Selection
-------------*/
::selection{color:#fff;background-color:#2d917f}
::-moz-selection{color:#fff;background-color:#2d917f}
<header>
<div id="logo">
<img src="https://ap-images.ga/up/2017/05/11151821-Logo2.svg" title="11145933-Logo.svg" alt="11145933-Logo.svg"/>
</div>
</header>
<main>
</main>
在 Codepen 上:https://codepen.io/RafaelDeJongh/pen/PmROPW
有没有人知道我最好如何解决这个问题,以及通常如何屏蔽元素中的特定部分(在本例中为标题)?
提前致谢!
最佳答案
最简单的解决方案就是制作一个 SVG:
然后将该 SVG 嵌入您的页面并覆盖您的横幅文本,或者将 SVG 保存为单独的文件并将其用作 background-imaage
对于 <header>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1860 256">
<defs>
<mask id="hole">
<rect width="100%" height="100%" fill="white"/>
<g transform="translate(200,35)">
<rect x="1" y="1" width="118" height="178" fill="#000"/>
<path fill="white" d="M0.1,0h119.8v180H0.1V0 M3.2,33.2c0,13.8,0,27.7,0,41.5C18.6,75.1,33.9,80.4,46,90c-0.1-5.1,0-10.2-0.1-15.3
c16.3-0.2,32.7,5,45.6,15c12.2,9.5,22,22.9,25.4,38.1c-0.4-31.5,0-63-0.2-94.5C78.9,33.2,41.1,33.2,3.2,33.2 M3.6,77.9
c0,23,0,45.9,0,68.9c14.1,0,28.3,0,42.4,0c0-17.6,0-35.1,0-52.7C34.2,84,18.9,78.4,3.6,77.9 M49,78c0.1,4.8,0,9.5,0,14.2
c15.5,13.6,25.1,33.8,25,54.5c14.1,0,28.3,0,42.4,0c0.5-17.7-7.1-35.2-19.3-47.8C84.7,86.1,67,78.2,49,78 M49.1,96.6
c0.1,16.7,0,33.4,0,50.2c7.3,0,14.6,0,21.8,0C70.9,128,62.6,109.6,49.1,96.6z"/>
</g>
</mask>
<filter id="shadow">
<feOffset in="SourceAlpha" dx="10" dy="10" result="offset" />
<feColorMatrix in="offset" type="matrix" values="0 0 0 0 0.5 0 0 0 0 0.5 0 0 0 0 0.5 0 0 0 1 0" result="greyoff" />
<feGaussianBlur in="greyoff" stdDeviation="7" result="blur" />
<feBlend in="SourceGraphic" in2="blur" mode="normal" />
</filter>
</defs>
<g filter="url(#shadow)">
<rect x="15" y="15" width="1800" height="220" fill="white" mask="url(#hole)"/>
</g>
</svg>
关于html - SVG/CSS : Masked Header Logo,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43919717/
谁能看看这个 fiddle http://jsfiddle.net/pkcwtone/1/并告诉我为什么我无法将图像完全放入导航中? 这是 html:
到目前为止,我有 9 个 Logo ,并且我按列表顺序显示该 Logo 。现在我要做的是,我必须显示前 3 个 Logo 并等待几秒钟,然后隐藏该 3 个 Logo 并再次显示接下来的 3 个 Log
我正在尝试 ACSLogo(Mac 版本的 Logo)中的递归程序,并希望返回 2 个整数的列表(基本上是 X 坐标和 Y 坐标)。我不知道如何让它返回 2 个值。它没有问题。 此外,当您创建一个列表
我有一个用户以 PNG 格式上传的 Logo 。 我的目标是将用户上传的 Logo 转换为白色。 像这样 - 这样它在较暗的背景下看起来不错。 我可以导出它并使用 Photoshop 获得我想要的东西
经过多次研究后,我没有弄清楚如何将我的 Web 应用程序的 Logo 与导航项对齐。我创建了 Logo 图像,但无法以正确的方式对齐它!希望你们中的一些人能帮助我。 这是Haml代码 %heade
我在 Joomla 2.5 的模板上使用 Gantry 该模板在第一点设置为托管一个小图像作为 Logo ,但我希望它在宽度方面更改为更大的图像。 因此,现在它在 ipad 上不起作用,因为它开箱即用
我正在工作的站点的 Logo 出现在左侧,但我希望它居中。我该怎么办?在下方找到 CSS 代码。 header .logo{ display: inline-block; padding: 0; ve
我确信这使用 jquery 相当简单,但我无法弄明白。我有一个带有 Logo 的网站,该网站加载时会出现。当用户将鼠标悬停在某个导航链接上时,我想将该 Logo 与不同的 Logo 交换。 当鼠标悬停
我想知道使用 LOGO 是否有任何真正的缺点?我知道它是用来教 child 的,但理论上它可以用于更高级别的项目。除了它的许多不同版本之外,还有什么真正的缺点吗? 最佳答案 除了实际问题(跨平台支持、
我一直在尝试使用公司文档中发布的两种简单方法替换 JASPERSOFT CE 中的 Logo 和背景图像。我面临的问题是它从 MYSQL 数据库加载 _THEMES\5A5D753\IMAGES\LO
当用户将鼠标悬停在导航栏上时,我试图让我的 Logo 从透明背景变为填充背景。 目前,我的 JQuery 在悬停时工作,但当用户离开导航时, Logo 不会变回透明 Logo 。
我知道之前已经回答过类似的问题。但我无法弄清楚哪种方法是最好的。我发现有两种方法: 使用img 标签获取两张图片,一张是小尺寸的,一张是大尺寸的。在大屏幕上隐藏小尺寸 Logo ,在小尺寸屏幕上则相反
我在页眉中使用的 Logo 没有背景,但我在 Logo 悬停时添加了背景。我希望 Logo 背景放大,但我使用的代码使 Logo 放大而不是背景......如何更改代码以在不影响 Logo 的情况下放
我试图将 Logo 与其下方的相应文本水平对齐,以便它们看起来美观且有序。目前,它们只是垂直的。我搜索了这个网站和许多其他网站,并尝试了不同的解决方案,但似乎没有任何效果。这是我的代码。 .intro
我正在尝试调整 Logo 的大小,并在不调整导航栏大小的情况下将标题添加到 Logo 的一侧。 What the current navbar looks like HTML:
Toggle navigation
在我的网站上,我有一个 Logo 图像,然后是公司名称。目前它是堆叠的,所以它是 Logo 图像,下面是公司名称。 我想要的是他们肩并肩。因此,左侧是 Logo 图像,右侧是公司名称。 我做错了什么?
我读过 标签 is inappropriate for a logo .但是,如果您的 Logo 是纯文本,您应该使用什么?我觉得 和 也不合适。这是一个示例: Comp
Berkeley Logo User Manual 告诉我们,所有在连字符后的命令行参数都将收集在变量中: If a command line argument is just a hyphen, t
我试图将 Logo 与几个导航链接对齐,其中大多数网站的 Logo 在左侧,几个链接在右侧(这是我正在努力实现的目标)。 我有一个媒体查询,使标题 Logo 显示在导航链接上方。 但是好像不行。 我确
我是一名优秀的程序员,十分优秀!