深夜问题个 css 样式重用问题

2016-01-09 00:45:37 +08:00
 boyhailong

比如我想定制一个 button 用的时候只是透明度 背景不一样 怎么写才最好,现在最笨的办法是:
.button-allen {
background:url('{% static 'img/apple-touch-icon-114.png' %}') center;
opacity: 0.5;
width:35px;
height: 35px;
border-radius:80%;
background-size: cover;
zoom: 1;
}
.button-allen:hover {
background:url('{% static 'img/apple-touch-icon-114.png' %}') center;
opacity: 1;
width:35px;
height: 35px;
border-radius:80%;
background-size: cover;
zoom: 1;
}

一个 button 就这么多代码,用多个还不写死, google 了半天语法 无奈不知道搜索什么,估计是关键词不对,貌似还有哥 sass 的,求助 😳

3035 次点击
所在节点    CSS
5 条回复
wulongqiu
2016-01-09 00:56:50 +08:00
.button-allen, .button-allen:hover {
background:url('{% static 'img/apple-touch-icon-114.png' %}') center;
opacity: 0.5;
width:35px;
height: 35px;
border-radius:80%;
background-size: cover;
zoom: 1;
}
.button-allen:hover {
opacity: 1;
}
最简单的是这样, CSS 是后边覆盖前边的。
可以搜索: CSS 重用
ck65
2016-01-09 01:04:57 +08:00
@wulongqiu 是不是第一行的 .button-allen:hover 也可以去掉?
hxsf
2016-01-09 02:05:27 +08:00
难道不是这么写的咩。。。

```css
.button-allen {
background:url('{% static 'img/apple-touch-icon-114.png' %}') center;
opacity: 0.5;
width:35px;
height: 35px;
border-radius:80%;
background-size: cover;
zoom: 1;
}
.button-allen:hover {
opacity: 1;
}
```
SourceMan
2016-01-09 09:30:26 +08:00
呵呵
boyhailong
2016-01-09 13:16:31 +08:00
@wulongqiu 还是没有解决 因为用了 pure 很蛋疼的 pureutton 麻烦点修改了下 也能看 但麻烦
还有一个问题 sidebar 的位置有点偏下 不知道怎么调整
如下图
<img>src=" "</img>

看不到的话直接看主页吧 https://allenzhao.herokuapp.com/

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/249429

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX