简体   繁体   English

为div角和边框添加繁荣的技术:CSS3多个背景或边框图像?

[英]Technique for adding flourishes to div corners and borders: CSS3 Multiple Backgrounds or Border Images?

I'm 'embellishing' an existing website with some nice flourishes to the corners and borders of a content div . 我正在“装饰”一个现有的网站,内容div的角落和边界有一些不错的繁荣。 Without changing the markup at all (as it is generated by a CMS), how can I add 'flourish' images (ie corner flourishes like this ) and fancy borders using CSS only? 根本不改变标记(因为它是由CMS生成的),我怎样才能添加“蓬勃发展”的图像(即像这样的角落繁荣 )和仅使用CSS的花式边框?

Fancy ASCII Art representation of what I want to achieve (outer border represents div): 我希望实现的花式ASCII艺术表示(外边框代表div):

---------------------------------------------
|                                           |
|  #%%%      ....................      %%%# |
|  %                                      % |
|  %                                      % |
|                                           |
| .                                       . |
| .                                       . |
| .                                       . |
| .                                       . |
| .                                       . |
| .                                       . |
| .                                       . |
| .                                       . |
| .                                       . |
| .                                       . |
| .                                       . |
|                                           |
| %                                       % |
| %                                       % |
| #%%%      ....................       %%%# |
---------------------------------------------

The div can expand vertically. div可以垂直扩展。 It needs to work across browsers (CSS3PIE is being used). 它需要跨浏览器工作(正在使用CSS3PIE)。 And the div already has a background image. div已经有了背景图片。

Is CSS3 Multiple Backgrounds the way to go? CSS3多重背景可行的吗? Or are CSS3 Border Images the best way? 或者CSS3边框图像是最好的方法吗?

Which technique will give the best flexibility in terms of the handling the vertically expanding div as well as how far inset the borders / corners can be? 哪种技术在处理垂直扩展div以及边界/角落插入的距离方面具有最大的灵活性?

The syntax should be something like this: 语法应该是这样的:

.flourish{
width: 500px; /* just an example */
height: auto;
background-image: url(decoration1.png), url(decoration2.png), url(decoration3.png), url(decoration4.png), url(background.jpg);
background-repeat: no-repeat;
background-position: left top, right top, right bottom, left bottom, left top;
}

Kind of nasty having all those images to load... If the width is fixed then you could just have a top and bottom ornament background. 有点讨厌加载所有这些图像...如果宽度是固定的,那么你可以只有一个顶部和底部装饰背景。

It would be even better if you could use the same image and just rotate it using css, but I am not aware of any background property to handle that. 如果你可以使用相同的图像并使用css旋转它会更好,但我不知道有任何背景属性来处理它。

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

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