javascript - 如何使用图像提供边框和 Angular 在 HTML/CSS3/jQuery/Javascript 中创建一个完美可伸缩的按钮?

标签 javascript jquery html css

如何使用图像提供边框和 Angular 在 HTML/CSS3/jQuery+Plugins 中创建一个完美可缩放的按钮?

我想到了一个绝对乱七八糟的方法,我相信还有更好的方法来解决这个问题。

我的方法是这样的:

<div class="button-container">  

    // The corners are all the same image, just rotated for the specific corner
    // (using CSS)

    <div class="top-right"></div>
    <div class="bottom-right"></div>
    <div class="top-left"></div>
    <div class="bottom-left"></div>


    // The (height, width) of the top/bottom edge are (5px,1px), so they can
    // repeat-x (or be stretched infinitely with no loss of quality), likewise
    // for the left/right edges, they can repeat-y (or again be stretched).

    <div class="top-edge"></div>
    <div class="bottom-edge"></div>
    <div class="left-edge"></div>
    <div class="right-edge"></div>


    // This simply fills the center of the button, with padding on every
    // edge to allow for transparency on the corners.

    <div class="center-fill"></div>
</div>

能够解决我的问题的人可以看到问题所在。

根据要求提供更多信息/说明。

编辑:不知道你为什么需要 fiddle ,我的方法很容易解释,如果你不明白的话 Smart way to add corner image to DIV border on all four corners

虽然这并没有解决我的问题,但我的方法正是我不使用的方法。我正在尝试制作一个可缩放的按钮,类似于纯 CSS3 按钮的可缩放性。如果我希望我的图像的顶部边缘边框是水平拉伸(stretch)或在 x 轴上重复的 1 像素宽 5 像素高的图像,我必须使用图像。我想要一个用图像和 CSS“技巧”构建按钮的优雅解决方案。

最佳答案

尝试使用边框图像,这里给出了一个很好的例子:

http://www.css3.info/preview/border-image/

border-image: url(border.png) 27 27 27 27 stretch stretch;

http://www.css3.info/images/border-image1.gif

您可以像这样为 Angular 使用不同的图像:

border-image:
    border-top-image
    border-right-image
    border-bottom-image
    border-left-image

border-corner-image:
    border-top-left-image
    border-top-right-image
    border-bottom-left-image
    border-bottom-right-image

关于javascript - 如何使用图像提供边框和 Angular 在 HTML/CSS3/jQuery/Javascript 中创建一个完美可伸缩的按钮?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19723813/

相关文章:

javascript - 在当前浏览器中对 ES2015 新数据类型(例如 Set)进行子分类

php - 更改数据库验证的日期格式

javascript - 当 url 包含 anchor 时,在页面加载时获取网页滚动条的垂直位置

javascript - $.each 在 $.append 里面(对象 [object Array] 没有方法 'apply' )

javascript - 关于帖子、评论、保存和喜欢的 Mongodb 数据结构

javascript - Chrome 打开包含 url 的选项卡

jquery - 在 jQuery 和 Servlet 之间传递数据

java - 在 Java Servlet 中按下按钮后看不到表格

html - 为什么此图像链接(<a> 标记内的 HTML <img> 标记)不起作用?

javascript - 如何通过 Javascript 在两个 div 之间添加一个 div