英文:
How do I set this shadow effect in an image around a div element?
问题
这是我想要的图像:
<a href="https://i.stack.imgur.com/wRSLl.png"><img src="https://i.stack.imgur.com/wRSLl.png"></a>
我想要在一个元素周围创建类似的浅灰色阴影效果;
我尝试设置与边框相关的CSS属性,但效果不理想。
我的想法是使用CSS的渐变效果,但我对CSS的渐变不是特别熟悉。
英文:
Here's an image of what I want:
<a href="https://i.stack.imgur.com/wRSLl.png"><img src="https://i.stack.imgur.com/wRSLl.png"></a>
I want to have a similar light gray shadow effect around an element;
I tried setting CSS properties related to the border, but it didn't work out.
My idea is to use the gradient effect of css, but I am not particularly familiar with the gradient of css.
答案1
得分: 1
你可以使用 box-shadow
CSS 属性:
/* 水平偏移量 | 垂直偏移量 | 模糊半径 | 扩展半径 | 颜色 */
box-shadow: 0 0.25rem 1rem 0.25rem rgba(0, 0, 0, 0.05);
<button class="my-btn">待评价</button>
英文:
You can use the box-shadow
CSS property:
/* offset-x | offset-y | blur-radius | spread-radius | color */
box-shadow: 0 0.25rem 1rem 0.25rem rgba(0, 0, 0, 0.05);
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-css -->
body { padding: 1em; }
.my-btn {
background: #FFF;
padding: 0.25em 1em;
border: none;
border-radius: 1.5em;
box-shadow: 0 0.25rem 1rem 0.25rem rgba(0, 0, 0, 0.05);
font-size: 2em;
}
.my-btn:hover {
cursor: pointer;
box-shadow: 0 0.25rem 1rem 0.25rem rgba(0, 0, 0, 0.15);
}
.my-btn:active {
background: #222;
color: #EEE;
box-shadow: 0 0.25rem 1rem 0.25rem rgba(0, 0, 0, 0.5);
}
<!-- language: lang-html -->
<button class="my-btn">待评价</button>
<!-- end snippet -->
答案2
得分: 0
尝试这个:
Css:
.btn {
width: 200px;
height: 150px;
border: none;
outline: none;
box-shadow: 2px 2px 12px 2px #efefef;
border-radius: 8px;
}
Html:
<div class="btn">你好</div>
英文:
Try this:
Css:
.btn {
width:200px;
height:150px;
border:none;
outline:none;
box-shadow:2px 2px 12px 2px #efefef;
border-radius:8px;
}
Html:
<div class="btn">Hello</div>
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论