设计表单时的蓝图 CSS 以及演示文稿和内容的分离
是否可以使用 Blueprint CSS 并在表示和内容之间保持相当程度的分离?我喜欢框架在设计表单时的易用性,但担心我使用 css 类对元素进行列化的方式是一种不好的做法。
例如,假设我有一个使用蓝图设计的 3 字段表单:
<div class="container">
<form action="" method="post" class="inline">
<fieldset>
<legend>Example</legend>
<div class="span-3">
<label for="a">Label A:</label>
<input type="text" class="text" id="a" name="a" >
</div>
<div class="span-2">
<label for="b">Label B:</label>
<input type="text" class="text" id="b" name="b" >
</div>
<div class="span-3">
<label for="o">Label O:</label>
<input type="checkbox" id="o" name="o" value="true" checked="checked" class="checkbox">checkbox one
</div>
<div class="span-2 last">
<input type="submit" value="submit" class="button">
</div>
</fieldset>
</form>
</div>
使用名称为“span-2”、“inline”和“last”的类属性是一种不好的做法吗?或者我错过了重点?
更新
对此进行了更深入的讨论: 内容与呈现分离的神话
Is it possible to use Blueprint CSS and maintain a a respectable level of separation between presentation and content? I like how easy the framework is to use when designing forms, but am worried that the manner in which I use the css classes for columnizing elements is a bad practice.
For instance, say I have a 3 field form designed using blueprint:
<div class="container">
<form action="" method="post" class="inline">
<fieldset>
<legend>Example</legend>
<div class="span-3">
<label for="a">Label A:</label>
<input type="text" class="text" id="a" name="a" >
</div>
<div class="span-2">
<label for="b">Label B:</label>
<input type="text" class="text" id="b" name="b" >
</div>
<div class="span-3">
<label for="o">Label O:</label>
<input type="checkbox" id="o" name="o" value="true" checked="checked" class="checkbox">checkbox one
</div>
<div class="span-2 last">
<input type="submit" value="submit" class="button">
</div>
</fieldset>
</form>
</div>
Is using a class attribute with names like "span-2", "inline", and "last" a bad practice? Or am I missing the point?
UPDATE
This is talked about in more depth at:
THE MYTH OF CONTENT AND PRESENTATION SEPARATION
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我想说你没有抓住重点。如果你想设计这些元素的样式,无论如何,你都必须给它们一个类或ID,并且只要保持一致,任何命名约定都可以变得有意义。喜欢抱怨类名的人通常都不是很好的设计师。
I'd say you're missing the point. If you want to style those elements you're going to have to give them a class or ID regardless, and any naming convention can become meaningful so long as it remains consistent. The people who like to complain about the names of your classes generally aren't very good designers.
我想说这是不好的做法。您应该想出更有意义的类名和 id,直接应用于您的标记,然后使用这些“使用”内容,例如
span-2
和last
。这可以使用蓝图的compress.rb
来完成。有关使用的详细信息可以在这里找到:http://jdclayton.com/blueprints_compress_a_walkthrough.html
特别是对于您所谈论的内容,您应该注意“semantic_classes”部分。
I would say it is bad practice. You should be coming up with more meaningful class names and ids that apply directly to your markup and then have those "use" things such as
span-2
andlast
. This can be done using blueprint'scompress.rb
.Details on using that can be found here: http://jdclayton.com/blueprints_compress_a_walkthrough.html
In particular to what you are talking about, you should be paying attention to the "semantic_classes" part.