CSS divs。 [英] CSS divs.

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

问题描述

这是一个问题,我相信你们中的一些人可以迅速回答,但是。我一直在学习如何编写使用Xhtml和CSS的代码。我对一些CSS属性感到困惑。


我知道类和id用于设置某些元素,例如< p>等等,但是和< div>之间的区别是什么?和< span>两者都允许你命名代码的各个部分,并且你可以设置样式,如背景图像,文本颜色和类似的东西。


我想要做的就是代码布局。它应该是一个简单的2 collum。所以说我有一个想要成为内容背景的图像。我是否使用类,ID,div或跨度?那个导航侧边栏的东西呢?跨越Divs ahhhh它如此令人困惑

This is a question that i am sure some of you can answer quickly, but anway. I have been learning how to code useing Xhtml and CSS. I am confused about some CSS properties.

I know classes and ids are for styling certain elements like <p> and such, but what is the difference between that and <div> and <span> both allow you to name sections of your code, and for both you can set style like background image, text color and stuff like that.

Bassically what I am trying to do hear is code a layout. It''s supposed to be a simple 2 collum one. So say I have an image of what I want to be the content backround. Do I use classes, ids, divs, or spans? What about the navigation sidebar thing? Spans Divs ahhhh its so confusing

推荐答案

我无法回答你的许多问题......但我总是想到< span>,< ;>和< DIV>除了< span>之外,所有工作方式都相同< DIV>可以用来更好地在文档的特定部分执行JavaScript。


关于导航栏的问题,我建议您使用框架集和单独的HTML文档导航栏......
I can''t answer many of your questions...but it has always occurred to me that <span>, <p>, and <DIV> all work the same way, except <span> <DIV> can be used to better carry out a JavaScript in a specific part of a document.

As for your question about a navigation bar, I suggest you use framesets and a seperate HTML document for the nav bar...



我建议您使用框架集和导航栏的单独HTML文档...
I suggest you use framesets and a seperate HTML document for the nav bar...



框架集导致太多问题,特别是因为使用CSS可以更容易地完成。

Framesets cause too many problems, especially since it can be done so much easier with CSS.


它总是发生在我< span>,< p>和< DIV>所有工作方式都相同
it has always occurred to me that <span>, <p>, and <DIV> all work the same way



完全没有。


A< div>是一个结构元素,用于帮助包含需要与其他元素分离的相似元素。它是''块级''。在布局页面时,人们做的第一件事就是在页面中添加div。但是,并不总是需要div。


< span>用于包含''内联元素'',例如段落中的元素。跨度本身就是内联。


您可以使用span来应用某个属性,或者包含段落内的内容。你使用div来应用属性,或者包含元素块,例如整个段落,表格和其他div。


所以跨度不能用于div并且div不能使用内部段落。


类和id仅用于命名元素,因此您可以识别它们并以不同方式使用它们。如果我想要一个< p>我可以将它们标记为< p id =" jack">和< p id =" jill>。然后在css:

#jack {

font-size:12px

}

#jill {

字体大小:16px;

}


但是,你只能有一个< p>在页面上称为杰克或吉尔。因此,如果我的页面充满了千斤顶和jill,那么我只是将它们全部放在同一类别或类别中。


< p class =" jack>和< p class =" jill>


.jack {

font-size:12px

}

.jill {

font-size:16px

}

Not at all.

A <div> is a structural element used to help with containing ''like elements'' that need to be separated from other elements. It is ''block level''. When laying out pages, the first thing too many people do is add divs to the page. However, divs are not always needed.

<span> is used to contain ''inline elements'' such as those in a paragraph. Span, itself, is ''inline''.

You use span to apply some attribute, or to contain, content that is inside a paragraph. You use a div to apply attributes, or contain, blocks of elements, such as whole paragraphs, tables, and other divs.

So spans cannot be used on divs and divs cannot be used inside paragraphs.

Classes and ids are only used to name elements so you can identify them and use them differently. If I want one <p> to have a different font than another, I can id them as <p id="jack"> and <p id="jill>. Then in css:
#jack{
font-size:12px
}
#jill{
font-size:16px;
}

But, you can only have one <p> called jack or jill on a page. So, if my page is filled with jacks and jills, then I just put them all in the same category, or class.

<p class="jack> and <p class="jill>

.jack{
font-size:12px
}
.jill{
font-size:16px
}



类和id仅用于命名元素,因此您可以识别它们并以不同方式使用它们。如果我想要一个< p>我可以将它们标记为< p id =" jack">和< p id =" jill>。然后在css:

#jack {

font-size:12px

}

#jill {

字体大小:16px;

}


但是,你只能有一个< p>在页面上称为杰克或吉尔。所以,如果我的页面充满了插孔和jill,那么我只是将它们全部放在同一类别或类中。
Classes and ids are only used to name elements so you can identify them and use them differently. If I want one <p> to have a different font than another, I can id them as <p id="jack"> and <p id="jill>. Then in css:
#jack{
font-size:12px
}
#jill{
font-size:16px;
}

But, you can only have one <p> called jack or jill on a page. So, if my page is filled with jacks and jills, then I just put them all in the same category, or class.



这是不正确的; ID可以多次使用,就像类可以一样。

This is incorrect; IDs can be used multiple times, just like classes can.


这篇关于CSS divs。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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