混合百分比和固定CSS [英] Mixing percent and fixed CSS

查看:138
本文介绍了混合百分比和固定CSS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是来自UI.StackExchange.com的重复:

http://ui.stackexchange.com/questions/1004/mixing-percent-and-fixed-css



如果您应用百分比和固定CSS在一起?




  • 混合是否会降低浏览器的渲染性能?




下面只是一个混合使用的例子,它可以是任何混合物。 我不是在寻找验证的例子。我听说你不应该做我在下面的例子,所以我试图找出是否使用CSS在这种方式是一个问题。 / p>

混合使用示例:

  ; style> 
.container
{
width:300px;
}
.cell
{
width:25%;
}
< / style>

< table class =container>
< tr>
< td class =cell>< td>
< td class =cell>< td>
< td class =cell>< td>
< td class =cell>< td>
< / tr>
< / table>


解决方案

+1好问题。您可能需要查看本文:固定宽度,液体和弹性布局它跨越固定宽度布局(em)和弹性布局(%),如果你点击进入下一页,它看看'弹性液体混合' - 其中宽度:设置单向,与最大宽度:设置其他。我知道上面链接的文章不是你所要求的,而是一个单一CSS样式中混合使用的例子。






编辑:经过一些进一步的阅读,我发现在这个问题上有很多矛盾的观点。我发现了几篇文章,认为你不能混合像素和百分比。虽然,在大多数情况下,这些网站是相当过时的。当我将搜索范围缩小到过去一年中提到的文章时,情况有所改变。还有一些意见反对混合,但他们通常没有解释为什么,似乎我总是听到这是一个坏主意品种。
我在这个主题上发现的大多数最新信息似乎表明,混合百分比与固定宽度是一个完全可以接受的做法,只要做了对结果的理解



请参阅:





披露:我已经是调音台多年了,没有真的知道我的方法是否正确。


This is a duplicate from UI.StackExchange.com:
http://ui.stackexchange.com/questions/1004/mixing-percent-and-fixed-css

Should you ever apply percentage and fixed CSS together? Will it cause problems, and if so what kinds?

  • Does mixing degrade browser render performance?
  • Will mixing give you weird results on initial load with progressive rendering browsers?

Below is just a dumbed-down example of mixed usage, it could be any mixture. I am not looking for validation of the example. I have heard you should never do what I have in the example below, so I am trying to find out if using CSS in this manner is an issue.

Example mix usage:

<style>
.container
{
    width:300px;
}
.cell
{
    width:25%;
}
</style>

<table class="container">
     <tr>
        <td class="cell"><td>
        <td class="cell"><td>
        <td class="cell"><td>
        <td class="cell"><td>
     </tr>
</table>

解决方案

+1 Good question. You may want to have a look at this article: "Fixed-width, liquid, and elastic layout" It goes over fixed width layout (em) and elastic layouts (%), and if you click to go to the next page it looks at 'Elastic-liquid hybrid' - where width: is set one way, with max-width: set the other. I know the article linked to above isn't exactly what you asked, but it's an example of mixed use within a single CSS style.


Edit: After some further reading I did find a quite a few contradictory opinions on the subject. I found several articles that held the idea that "you just can’t mix up pixels and percentages". Though, for the most part, these sites were fairly dated. When I narrowed the search to only articles that have been put up within the past year, things changed a bit. There were still a few opinions against mixing, but they typically didn't explain why, and seemed to of the "I always heard it was a bad idea" variety. The majority of more recent information that I've found on the topic seems to indicate that mixing percentage with fixed widths is a perfectly acceptable practice, as long as it's done with an understanding of the results.

see:

Full Disclosure: I've been a mixer for many years, without really knowing whether my approach was 'correct.'

这篇关于混合百分比和固定CSS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆