【问题标题】:css: Use single-sided outline and outline-offset?css:使用单面轮廓和轮廓偏移?
【发布时间】:2022-01-19 23:32:50
【问题描述】:

我想为带有outlineoutline-offset 的图像添加一个内部框架,但只在顶部和底部,但是没有outline-offset-topoutline-offset-bottomoutline-offset-left 或@ 这样的东西987654326@.

有没有人知道这样做的任何方法或替代方法?

img {
    vertical-align: middle;
    border-style: none;
    outline: 70px solid white;     
    outline-offset: -70px;
}
    <img src="https://cdnnmundo1.img.sputniknews.com/img/07e5/08/17/1115327694_182:0:2230:2048_1920x0_80_0_0_0642590b6896368f2c051719f7c66ea7.jpg">

【问题讨论】:

    标签: html css image border


    【解决方案1】:

    使用剪辑路径剪切顶部而不是添加白色

    img {
      clip-path:inset(70px 0 0);
    }
    <img src="https://cr.epaenlinea.com/pub/media/version20200605/catalog/product/cache/a83b746ef25730b9cb1cc414bac0f04a/1/2/1246118_3.jpg">

    【讨论】:

    • 感谢您的回答,有什么方法可以给消失的区域添加背景?
    猜你喜欢
    • 1970-01-01
    • 2012-01-04
    • 2020-04-05
    • 2021-10-01
    • 2021-07-09
    • 2014-11-21
    • 2018-03-18
    相关资源
    最近更新 更多