Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/image/5.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
用CSS实现图像的圆形阴影_Css_Image_Rounding_Shadow - Fatal编程技术网

用CSS实现图像的圆形阴影

用CSS实现图像的圆形阴影,css,image,rounding,shadow,Css,Image,Rounding,Shadow,我想为一个图像创建一个圆形阴影,为CSS创建一个按钮,我找到了一个解决方案,可以为一个框创建圆形阴影 但我不知道如何为我的案例应用代码(用于图像和按钮) 我们将感谢您的支持 将图像放置在框内,这将为图像创建阴影 <div id='DIV' class='box'> <img src='imgsrc' /> <!-- place your image here --> </div> 好的,创建一个html文档并粘贴以下代码: <

我想为一个图像创建一个圆形阴影,为CSS创建一个按钮,我找到了一个解决方案,可以为一个框创建圆形阴影

但我不知道如何为我的案例应用代码(用于图像和按钮)


我们将感谢您的支持

将图像放置在框内,这将为图像创建阴影

 <div id='DIV' class='box'>
    <img src='imgsrc' /> <!-- place your image here -->
 </div>

好的,创建一个html文档并粘贴以下代码:

<html>
<style type="text/css">
.box {
     position: relative;
     width: 400px;
     height: 300px;
     background-color: #fff;
     box-shadow: 0 1px 5px rgba(0,0,0,0.25), 0 0 50px rgba(0,0,0,0.1) inset;
     border-radius: 1%     1%     1%     1% /     1%     1%     1%     1%;
}
.box:after {
      position: absolute;
      width: 64%;
      height: 12%;
      left: 18%;
      border-radius: 50%;
      z-index: -1;
      bottom: 0%;
      content: "";
      box-shadow: 0 50px 24px rgba(0,0,0,0.24);
}
</style>
<body>
    <div class="box">
    <img src="img.jpg" />
    </div>
</body>
<html>

.盒子{
位置:相对位置;
宽度:400px;
高度:300px;
背景色:#fff;
盒影:0 1px 5px rgba(0,0,0,0.25),0 0 50px rgba(0,0,0,0.1)插图;
边界半径:1%1%1%1%/1%1%1%1%;
}
.盒子:之后{
位置:绝对位置;
宽度:64%;
身高:12%;
左:18%;
边界半径:50%;
z指数:-1;
底部:0%;
内容:“;
盒影:0.50px 24px rgba(0,0,0,0.24);
}
您必须在body内创建一个div元素,并将.box类指定给该div 像这样:

 <div class="box">
 // put your content here (eg. image or text) and it will be inside the box
 </div>

//把你的内容放在这里(如图像或文本),它就会在盒子里

仅此而已。

图像元素不允许在其内部放置伪元素,因此您必须将图像放置在div中,然后将样式应用于该div。

如果要使用相同的代码,则可以这样做

HTML:

<head id="Head1" runat="server">
    <title>Untitled Page</title>
    <style type="text/css">
        .box
        {

            position: relative;
            width: 400px;
            height: 300px;
            background-color: #fff;
            box-shadow: 0 1px 5px rgba(0,0,0,0.25), 0 0 50px rgba(0,0,0,0.1) inset;
            border-radius: 1% 1% 1% 1% / 1% 1% 1% 1%;
        }
        .box:after
        {
            position: absolute;
            width: 64%;
            height: 12%;
            left: 18%;
            border-radius: 50%;
            z-index: -1;
            bottom: 0%;
            content: "";
            box-shadow: 0 50px 24px rgba(0,0,0,0.24);
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div>
            <asp:Image ID="Image1" CssClass="box" ImageUrl="YourImagePath" runat="server" />       
    </div>
     <div >
         <asp:Button CssClass="box" ID="Button1" runat="server" Text="Button" />
    </div>
    </form>
</body>

无标题页
.盒子
{
位置:相对位置;
宽度:400px;
高度:300px;
背景色:#fff;
盒影:0 1px 5px rgba(0,0,0,0.25),0 0 50px rgba(0,0,0,0.1)插图;
边界半径:1%1%1%1%/1%1%1%1%;
}
.盒子:之后
{
位置:绝对位置;
宽度:64%;
身高:12%;
左:18%;
边界半径:50%;
z指数:-1;
底部:0%;
内容:“;
盒影:0.50px 24px rgba(0,0,0,0.24);
}
请根据需要更改宽度和高度。
我希望这对您有用。

毕竟,我发现阴影在页面底部。毕竟,我发现阴影在页面底部。谢谢大家
<head id="Head1" runat="server">
    <title>Untitled Page</title>
    <style type="text/css">
        .box
        {

            position: relative;
            width: 400px;
            height: 300px;
            background-color: #fff;
            box-shadow: 0 1px 5px rgba(0,0,0,0.25), 0 0 50px rgba(0,0,0,0.1) inset;
            border-radius: 1% 1% 1% 1% / 1% 1% 1% 1%;
        }
        .box:after
        {
            position: absolute;
            width: 64%;
            height: 12%;
            left: 18%;
            border-radius: 50%;
            z-index: -1;
            bottom: 0%;
            content: "";
            box-shadow: 0 50px 24px rgba(0,0,0,0.24);
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div>
            <asp:Image ID="Image1" CssClass="box" ImageUrl="YourImagePath" runat="server" />       
    </div>
     <div >
         <asp:Button CssClass="box" ID="Button1" runat="server" Text="Button" />
    </div>
    </form>
</body>