郎朗坤
边框不支持百分比...但仍有可能...正如其他人指出的CSS规范,边框不支持百分比:'border-top-width','border-right-width','border-bottom-width','border-left-width' Value: | inherit Initial: medium Applies to: all elements Inherited: no Percentages: N/A Media: visual Computed value: absolute length; '0' if the border style is 'none' or 'hidden'正如你可以看到它说百分比:N / A。非脚本解决方案您可以使用包装器元素模拟百分比边界,您可以在其中进行以下操作:将包装器元素设置background-color为所需的边框颜色设置包装元素的padding百分比(因为它们受支持)将您的元素设置background-color为白色(或任何需要的颜色)这将以某种方式模拟您的百分比边界。这是使用此技术的具有25%宽度侧边框的元素的示例。示例中使用的HTML.faux-borders { background-color: #f00; padding: 1px 25%; /* set padding to simulate border */}.content { background-color: #fff;}