简体   繁体   English

如何通过响应式设计阅读无响应的文本?

[英]How can I read an unreponsive text over a responsive design?

Basically we have what is called a responsive design in HTML, but a part of real content served through our web page that comes from a very big database with product description was made with Dreamweaver. 基本上,我们使用HTML进行响应式设计,但是通过Dreamweaver制作了通过网页提供的部分真实内容,该内容来自具有产品描述的超大型数据库。 Therefore its html is something like this: 因此,它的html是这样的:

<div style="width: 950px; float: left;">
<div style="width: 20px; float: left;">&nbsp;</div>
<div style="width: 910px; float: left; color: #37444D; padding-top: 20px; font-size: 18px;">...</div>
</div>

What can we do to avoid this unresponsive content to screw up the entire web page? 为了避免这种无响应的内容弄乱整个网页,我们该怎么办?

This is a pretty common real-world problem. 这是一个非常常见的现实问题。 In an ideal world the presentation and content would be separate, but here it sounds like there's too much legacy data to manually clean up. 在理想的情况下,表示和内容是分开的,但是在这里听起来好像有太多的旧数据无法手动清理。

In this case I'd recommend using Javascript to replace the inline styles with relevant class names. 在这种情况下,建议您使用Javascript将内联样式替换为相关的类名。 The first thing this will do is remove all of your fixed widths, so you'll have something that fits with your responsive design. 要做的第一件事是删除所有固定宽度,因此您将拥有适合您的自适应设计的东西。

However, many of those styles were actually doing something so you should then write some responsive CSS to target your new-found classes, which will all have sensible (if not semantic) names. 但是,其中许多样式实际上都在做某事,因此您应该编写一些响应式CSS来定位您的新发现的类,这些类都具有明智的(如果不是语义的)名称。

If your site runs jQuery the the code could be as simple as: 如果您的网站运行jQuery,则代码可能很简单:

$("div").each(function() {
    var w = $(this).width();
    $(this).addClass("width" + w);
    $(this).removeAttr("style");
});

Demo fiddle with CSS: http://jsfiddle.net/5G374/1/ 用CSS演示小提琴: http : //jsfiddle.net/5G374/1/

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

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