热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

Firefox-mozilla-border-radius不会裁剪出图像吗?-Firefox-moz-border-radiuswon'tcropoutimage?

DoesanyoneknowawaytogetFirefoxtocropthecornersiftheborderradiusofanimageisset?I

Does anyone know a way to get Firefox to crop the corners if the border radius of an image is set? It's containing element will work fine but I get ugly corners sticking out.

如果设置了图像的边界半径,有没有人知道让Firefox裁剪角落的方法?它包含的元素可以工作,但我有难看的角落突出。

Any way to fix this without setting the image as a background image or processing it before I put it on my site?

有什么方法可以在不将图像设置为背景图像或在将其放到站点之前对其进行处理的情况下修复它吗?

9 个解决方案

#1


19  

Does it not crop if you apply the border radius directly to the img element? There are known issues with -moz-border-radius as far as contained content is concerned.

如果你直接对img元素施加边界半径,它会不会被裁剪?就包含的内容而言,有一些众所周知的问题。

--edit

——编辑

OK, it doesn't crop img either. If your image is some sort of png/gif on a solid background you may be able to do something like this:

好吧,它也不会伤害img。如果你的图片是某种固体背景上的png/gif,你可以做如下的事情:

img {
    border: 10px solid white;
    -moz-border-radius: 10px;
}

But if you're trying to get rounded corners on a photo then it's not going to work in 3.5.

但是如果你想在一张照片上画出圆角那么在3。5秒内是行不通的。

#2


21  

Workaround: Set the image as the background of a container element, then add border radius on that element.

工作区:将图像设置为容器元素的背景,然后在该元素上添加边框半径。

#3


3  

I think to have the answer but sorry for my english... I resolved the question putting another div with border and no background color over the image.

我想知道答案,但我的英语不好意思……我解决了在图像上放置另一个带有边框且没有背景颜色的div的问题。

#imageContainer {
  -webkit-border-radius:10px
  -moz-border-radius:10px;
  z-index:1;
}
#borderContainer {
  position:absolute;
  border:1px solid #FFFFFF;
  -webkit-border-radius:10px
  -moz-border-radius:10px;
   z-index:10;
}

#4


1  

Workaround: Set the image as the background of a container element, then add border radius on that element.

工作区:将图像设置为容器元素的背景,然后在该元素上添加边框半径。

This won't work unless the image is exactly the same size of the div. Unless you use the new css property in firefox 3.6 which allows for background image sizing, but hardly anyone is on 3.6 already.

除非图像的大小与div完全相同,否则这是行不通的。

So I agree with Alex, that is if you make the image the size of the div/other elm.

所以我同意Alex的观点,那就是如果你让图片的大小和div/other elm一样。

#5


1  

I don't think there is a way to use -moz-border-radius to directly round an image in FireFox. But you can simulate the rounded corners the old fashioned way, with extra markup.

我不认为有一种方法可以使用-moz-border-radius来直接在FireFox中使用图像。但是您可以使用额外的标记来模拟圆角。

So that looks like this:

看起来是这样的:

situation normal

Then the CSS:

CSS:

#container {position:relative;}
#container img {z-index:0;}
.rounded {position:absolute; z-index:1; width:20px; height:20px;}
.lt {background:url('images/rounded_LT.png') left top no-repeat;}
.rt {background:url('images/rounded_RT.png') right top no-repeat;}
.lb {background:url('images/rounded_LB.png') left bottom no-repeat;}
.rb {background:url('images/rounded_RB.png') right bottom no-repeat;}

The background images of the corners look sort of like a crescent moon, with transparency. This is a negative space technique, where you are allowing the image to show through where the corners have their transparency.

角落的背景图像看起来有点像新月,透明。这是一种负空间技术,你可以让图像通过角落的透明度显示出来。

Div corners with PNG-24 backgrounds will work very nicely. If you can deal with the jagginess, you can use GIF backgrounds for IE6, or just remove background image entirely for square corners. Use conditional comments to serve the CSS to IE6.

具有PNG-24背景的Div角落将非常好用。如果你能处理不整齐,你可以使用GIF背景为IE6,或者只是删除背景图像完全平方角。使用条件注释为IE6提供CSS服务。

#6


1  

.round_image_borders {

    position:relative; // fix for IE8(others not tested)
    z-index:1; // fix for IE8(others not tested)
    width:114px;
    height:114px;
    -moz-border-radius: 15px;
    -webkit-border-radius: 15px;
    border-radius: 15px;
    behavior:url(border-radius.htc); // fix for IE8(others not tested)
}

I got the "border-radius.htc" script from this link:

我得到了”这个特性。htc的脚本来自这个链接:

http://code.google.com/p/curved-corner/

http://code.google.com/p/curved-corner/

What it does it adds support for round corners for IE8. I also had to set position:relative and z-index, because otherwise the div(and the background image) would show under the desired div container in which the container(round_image_borders) div was put.

它增加了对IE8圆角的支持。我还必须设置位置:relative和z-index,否则div(以及背景图像)将显示在所需的div容器下,容器(round_image_borders) div将被放置在这个容器中。

This works for:

这适用于:

FF 3.6.16

FF 3.6.16

IE 8

IE 8

Chrome 12.0

Chrome 12.0

And yes, the image must have the same size as the div with the class round_image_borders. But this workaround is intended to be used with images that all have the same size.

是的,图像必须具有与具有类round_image_borders的div相同的大小。但是,这种方法的目的是与所有具有相同大小的图像一起使用。

#7


1  

If you use overflow: hidden it won't display the image corners sticking out.

如果使用溢出:隐藏它将不会显示突出的图像角。

Who knows, they still might be there, just hidden.

谁知道呢,他们可能还在那里,只是隐藏着。

#8


1  

img {
 overflow: hidden;

 -webkit-border-radius: 10px;
 -moz-border-radius: 10px;
 -o-border-radius: 10px;
 -ms-border-radius: 10px;
 border-radius: 10px;
}

#9


0  

Firefox does seem to clip a background image, so if you set an h1 background image and apply border-radius to that it will clip. (just verified in FF 3.6.12)

Firefox似乎确实会剪切一个背景图像,所以如果你设置一个h1背景图像并对其应用边框半径,它就会剪切。(仅在FF 3.6.12中验证)


推荐阅读
  • 生成式对抗网络模型综述摘要生成式对抗网络模型(GAN)是基于深度学习的一种强大的生成模型,可以应用于计算机视觉、自然语言处理、半监督学习等重要领域。生成式对抗网络 ... [详细]
  • 云原生边缘计算之KubeEdge简介及功能特点
    本文介绍了云原生边缘计算中的KubeEdge系统,该系统是一个开源系统,用于将容器化应用程序编排功能扩展到Edge的主机。它基于Kubernetes构建,并为网络应用程序提供基础架构支持。同时,KubeEdge具有离线模式、基于Kubernetes的节点、群集、应用程序和设备管理、资源优化等特点。此外,KubeEdge还支持跨平台工作,在私有、公共和混合云中都可以运行。同时,KubeEdge还提供数据管理和数据分析管道引擎的支持。最后,本文还介绍了KubeEdge系统生成证书的方法。 ... [详细]
  • 本文讨论了在Windows 8上安装gvim中插件时出现的错误加载问题。作者将EasyMotion插件放在了正确的位置,但加载时却出现了错误。作者提供了下载链接和之前放置插件的位置,并列出了出现的错误信息。 ... [详细]
  • CSS3选择器的使用方法详解,提高Web开发效率和精准度
    本文详细介绍了CSS3新增的选择器方法,包括属性选择器的使用。通过CSS3选择器,可以提高Web开发的效率和精准度,使得查找元素更加方便和快捷。同时,本文还对属性选择器的各种用法进行了详细解释,并给出了相应的代码示例。通过学习本文,读者可以更好地掌握CSS3选择器的使用方法,提升自己的Web开发能力。 ... [详细]
  • sklearn数据集库中的常用数据集类型介绍
    本文介绍了sklearn数据集库中常用的数据集类型,包括玩具数据集和样本生成器。其中详细介绍了波士顿房价数据集,包含了波士顿506处房屋的13种不同特征以及房屋价格,适用于回归任务。 ... [详细]
  • 本文介绍了如何使用PHP向系统日历中添加事件的方法,通过使用PHP技术可以实现自动添加事件的功能,从而实现全局通知系统和迅速记录工具的自动化。同时还提到了系统exchange自带的日历具有同步感的特点,以及使用web技术实现自动添加事件的优势。 ... [详细]
  • 微软头条实习生分享深度学习自学指南
    本文介绍了一位微软头条实习生自学深度学习的经验分享,包括学习资源推荐、重要基础知识的学习要点等。作者强调了学好Python和数学基础的重要性,并提供了一些建议。 ... [详细]
  • 如何自行分析定位SAP BSP错误
    The“BSPtag”Imentionedintheblogtitlemeansforexamplethetagchtmlb:configCelleratorbelowwhichi ... [详细]
  • Java太阳系小游戏分析和源码详解
    本文介绍了一个基于Java的太阳系小游戏的分析和源码详解。通过对面向对象的知识的学习和实践,作者实现了太阳系各行星绕太阳转的效果。文章详细介绍了游戏的设计思路和源码结构,包括工具类、常量、图片加载、面板等。通过这个小游戏的制作,读者可以巩固和应用所学的知识,如类的继承、方法的重载与重写、多态和封装等。 ... [详细]
  • GetWindowLong函数
    今天在看一个代码里头写了GetWindowLong(hwnd,0),我当时就有点费解,靠,上网搜索函数原型说明,死活找不到第 ... [详细]
  • Iamtryingtomakeaclassthatwillreadatextfileofnamesintoanarray,thenreturnthatarra ... [详细]
  • 在Android开发中,使用Picasso库可以实现对网络图片的等比例缩放。本文介绍了使用Picasso库进行图片缩放的方法,并提供了具体的代码实现。通过获取图片的宽高,计算目标宽度和高度,并创建新图实现等比例缩放。 ... [详细]
  • PHP图片截取方法及应用实例
    本文介绍了使用PHP动态切割JPEG图片的方法,并提供了应用实例,包括截取视频图、提取文章内容中的图片地址、裁切图片等问题。详细介绍了相关的PHP函数和参数的使用,以及图片切割的具体步骤。同时,还提供了一些注意事项和优化建议。通过本文的学习,读者可以掌握PHP图片截取的技巧,实现自己的需求。 ... [详细]
  • 本文主要解析了Open judge C16H问题中涉及到的Magical Balls的快速幂和逆元算法,并给出了问题的解析和解决方法。详细介绍了问题的背景和规则,并给出了相应的算法解析和实现步骤。通过本文的解析,读者可以更好地理解和解决Open judge C16H问题中的Magical Balls部分。 ... [详细]
  • [译]技术公司十年经验的职场生涯回顾
    本文是一位在技术公司工作十年的职场人士对自己职业生涯的总结回顾。她的职业规划与众不同,令人深思又有趣。其中涉及到的内容有机器学习、创新创业以及引用了女性主义者在TED演讲中的部分讲义。文章表达了对职业生涯的愿望和希望,认为人类有能力不断改善自己。 ... [详细]
author-avatar
mobiledu2502934573
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有