设计表单时的蓝图 CSS 以及演示文稿和内容的分离

发布于 2024-08-29 03:06:47 字数 1426 浏览 1 评论 0原文

是否可以使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

So要识趣 2024-09-05 03:06:47

我想说你没有抓住重点。如果你想设计这些元素的样式,无论如何,你都必须给它们一个类或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.

爱要勇敢去追 2024-09-05 03:06:47

我想说这是不好的做法。您应该想出更有意义的类名和 id,直接应用于您的标记,然后使用这些“使用”内容,例如 span-2last。这可以使用蓝图的 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 and last. This can be done using blueprint's compress.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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文