- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我有一个具有多个背景的按钮。其中一个背景是 CSS-sprite
(864px x 18px) 包含图标。
我正在尝试将背景添加到 <input>
元素使其成为带有图标的按钮。问题是,我不能使用 :before/:after
因为输入没有内容,所以我不能添加元素,指定它的比例并使用 background-size/position
.
这是我的:
.buttonUpInput {
background: rgba(0, 0, 0, 0.4), #7EB238;
background-image: none; /* fallback */
background-image: url("http://mysprite.png"), -webkit-gradient(radial, center center, 0px, center center, 100%, color-stop(rgba(52,109,28,1)), color-stop(rgba(52,109,28,0) )), -webkit-gradient(linear, left top, left bottom, from( #9ad945 ), to( #7eb238 ));
background-image: url("http://code.jquery.com/mobile/1.3.0/images/icons-18-white.png"), -webkit-radial-gradient(center, ellipse cover, rgba(52,109,28,1), rgba(52,109,28,0) ), -webkit-linear-gradient( #9ad945, #7eb238 );
background-image: url("http://code.jquery.com/mobile/1.3.0/images/icons-18-white.png"), -moz-radial-gradient(center, ellipse cover, rgba(52,109,28,1), rgba(52,109,28,0) ), -moz-linear-gradient( #9ad945, #7eb238 );
background-image: url("http://code.jquery.com/mobile/1.3.0/images/icons-18-white.png"), -ms-radial-gradient(center, ellipse cover, rgba(52,109,28,1), rgba(52,109,28,0) ), -ms-linear-gradient( #9ad945, #7eb238 );
background-image: url("http://code.jquery.com/mobile/1.3.0/images/icons-18-white.png"), -o-radial-gradient(center, ellipse cover, rgba(52,109,28,1), rgba(52,109,28,0) ), -o-linear-gradient( #9ad945, #7eb238 );
background-image: url("http://code.jquery.com/mobile/1.3.0/images/icons-18-white.png"), radial-gradient(ellipse at center, rgba(52,109,28,1) 67%, rgba(52,109,28,0) 69%), linear-gradient( #9ad945, #7eb238 );
background-attachment: scroll, scroll, scroll;
background-repeat: no-repeat, no-repeat, no-repeat;
background-position: -100px 50%, 7px 50%, center center;
background-size: 864px 18px, 20px 20px, auto auto;
background-clip: content-box, content-box, padding-box;
border: 1px solid #aaa;
-moz-border-radius: .7em;
-webkit-border-radius: .7em;
border-radius: .7em;
color: white !important;
font-size: 16px;
font-weight: 800;
padding: 2px 14px 4px 1px;
text-indent: 35px;
width: auto;
height: 2.25em;
cursor: pointer;
}
问题:
我可以尝试硬编码/调整按钮大小/宽度(我更喜欢灵活)来尝试使用 content-box/padding-box
,但我无法让它工作。我想知道是否有任何其他方法可以仅使用 CSS 实现此目的?
谢谢!
最佳答案
您几乎无法裁剪这样的背景。 SVG sprite stacks尽可能接近,但对它的支持非常差。
但是,您可以将输入更改为按钮元素:
button:before {
content: ' ';
width: 50px;
height: 50px;
background: url(http://placehold.it/50x50);
display: inline-block;
vertical-align: middle;
}
关于css - 如果 :pseudo elements are not available?,还有哪些其他方法可用于裁剪/剪辑背景图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15833144/
我已经为我的项目配置了 tailwindcss,但是在 npm run start 之后我得到了以下错误。 (node:7032) UnhandledPromiseRejectionWarning:错
我使用 create-react-app 创建了一个应用程序并且在尝试构建生产优化版本时遇到错误 yarn build : > yarn build help yarn run v1.9.4 $ re
我正在寻找一种将 :content 伪元素添加到空元素的方法,并遇到了 :empty CSS 伪选择器,它看起来像会达到我正在寻找的目的。基本上,我想添加一个通用消息,如“Nothing found”
Font Awesome 未提供 :after伪。是否可以使用 :after默认情况下而不是 :before伪? 例如,如果我使用:facebook那么图标应该使用:after而不是 :before
我想在禁用时更改切换按钮的颜色。我使用 :before fetaure of css 实现了这个切换。代码位于 https://jsfiddle.net/sachin8085/adm5t7rz/6/
我最近在 Firefox 中发现了一个警告 Warning: Unknown pseudo-class or pseudo-element 'hidden' 这是页面 http://eleven23.
我有一个多项式 data Poly a = Poly [a] 我希望能够做类似 fmap (take 3) polynomial 的事情但我不能,因为 Poly不是真正的仿函数,因为 f我在 fmap
我想将某种样式应用到一个元素的所有后代,除了一些。 这是我正在尝试实现的示例:http://jsfiddle.net/f8FLe/ .root * :not(.nested) { color:
我正在学习 Haskell 中的代数 DT。我想做的是创建一个新的 ADT 来“扩展”现有的 ADT。我找不到如何表达我想要的东西,有人可以建议替代模式或建议解决方案。我希望它们是不同的类型,但复制和
我现在正在通过将所有内容包含在一个函数中,将全局变量变成“伪全局变量”,从而从我的代码中删除大部分全局变量,这些全局变量都可以从该函数 block 内的任何地方访问。 (function(){ var
我正在尝试创建动画时间轴。当时间轴出现时,我正在使用滚动显示来触发动画。每个时间线条目都有一个左边框和一个伪元素 :before 与之关联。 :before 元素是一个标记每个时间线条目开始的点。当动
我的大脑并没有完全围绕这个:我正在使用我的 h1 上的 :before 和 :after 伪元素>。我的 h1 有一个 100% 宽度。 我希望 :after 是一个重复的背景图形,填充空白,后置文本
是否可以在 :before 伪类的内容中添加类或 ID?我知道这行不通,但是类似: #menu { height: 100px; width: 100px; } #menu:befor
假设我有一个带有下划线的跨度: Hello, I'm underlined text .underline { color: #444; font-size: 250%; display:
这个问题在这里已经有了答案: CSS selector with period in ID (3 个答案) 关闭 6 年前。
我正在尝试将 :after 伪元素移动到 div 的末尾,有点像页脚。 Some content here .box { height: 60vh; } .box:after {
在您指定内容之后,:AFTER 和:BEFORE 伪元素的默认display: 属性是什么。 是display: inline还是display: inline-block? 无法在 default
我遇到这样一种情况,我有两个元素在 DOM(邻居)中处于同一级别。当我悬停在 DOM 中之前的元素时,我希望显示它下面的元素。我还想访问我正在显示的元素的子元素并显示其 :before 伪元素。 SC
我有一个样式规则: .tabs li { border: 1px solid transparent; } .tabs li:not(:last-child):not(:nth-child(2
我有两个相同的 CSS 规则,但一个没有覆盖另一个。 我使用了 right 而不是 left 规则,但它不会覆盖 left 规则。另一方面 top 规则正在覆盖。我也使用了 !important 规则
我是一名优秀的程序员,十分优秀!