简体   繁体   English

如何将图像边框设置为图像的特定高度和宽度? HTML/CSS

[英]How to border image to a specific height & width to an image ? HTML / CSS

I have an image attached below for which I want to write css that will provide border to the image from left & bottom.我在下面附有一张图片,我想为其编写 css,以便从左侧和底部为图片提供边框。 I tried but my code is taking full border我试过了,但我的代码正在全边框

This is the required output that I want.这是我想要的必需输出。 在此处输入图片说明

 img{ border-top: 15px solid #faa633; border-right: 15px solid #faa633; border-left: 15px solid #faa633; }
 <img src="https://images.unsplash.com/photo-1494548162494-384bba4ab999?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&w=1000&q=80" style="height: 400px;width: 300px">

keep the border transparent and apply a gradient with a specific size:保持边框透明并应用特定大小的渐变:

 img { border: 15px solid transparent; background: linear-gradient(#faa633, #faa633) bottom left/ /* position */ 50% 40% /* width height */ border-box no-repeat; }
 <img src="https://picsum.photos/id/10/200/150" >

如果您只希望图像的两侧有边框,我建议使用 box-shadow。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM