以下為本站文章分類清單

  1. AJAXspacer
  2. ASPspacer
  3. CSSspacer
  4. Javascriptspacer
  5. Windows 應用程式spacer
  6. 網頁設計
  7. 評論、短文、雜文spacer
  8. 版主spacer
  9. 最新回應spacer

以下為本頁本文內容

定義語法

無論您是在 HTML 文件中定義體裁或是在另一份文件中定義,定義的語法都相同 每一個標題使用下面的格式來定義:

 

h3 { font-family: Arial }

這裡 h3 是標題之一 (在本例中,又正好是一個 HTML 語法 [譯者按:因為我們一直以H3作例子,而H3又 恰是 HTML 中的一個標題文字,所以我們一直以標題來當作用語,事實上體裁定義可以自由命名]), font-family: Arial 是一種體裁定義。體裁定義的語法(如前例)是特性和內含值,用冒號隔開 (屬性 這裡指的是一個元件能擁有的特殊質--好比字體、級數、顏色。 檔 內含值則是指定這個特性的特色--好比 新細明體、 24點、紅色) 參閱 CSS 屬性一覽表 裡面列出了完整的 CSS 屬性及其內含值 

體裁定義可以同時指定多個屬性只要用分號格開即可:

h3 { font-family: Arial; font-style: italic; color: green } 

為了增加可讀性,可以寫成如下:

h3  { font-family: Arial;      font-style: italic;      color: green }

也可以在一個屬性中定義超過一個內含值,依順序寫入,用逗號隔開

h3  { font-family: Arial, Helvetica, sans-serif;     font-style: italic;     color: green }

上面 font-family 這個屬性提供了流覽器 數個內含可供選用,流覽器會依序尋找到可用的字體時,用該字體顯示文件。 第一個寫入的內含值是 (Arial) 表示我們最想用這個字體。 接下來的 (Helvetica) 則是找不到第一種字體時用這個字體來替代。 第三個 (sans-serif) 則是一般常見字體,建議您加在最後一項因為幾乎 所有電腦都有的字體。 如果前列的字體都不存在時,流覽器就會用自己內定的字體來顯示了。 (譯者按:例如中文網頁,那就可以寫成 font-family:華康細明,文鼎細明,新細明體 等的...)

使用 classes 和 IDs 檔作是體裁定義中的一個元件 

任何一個 HTML 標籤都可以拿來當作是一個體裁元件, 但有時您則想在您的定義中指定更多的體裁元件。例如: 假設您有一個大表格,包含了很多列,而且您想指定這些列包含了四種不同的顯示方式, 使用 <TR> 標籤當作是一個體裁元件時會限制您只能有一種體裁,那麼您所有列的內容看起來會一模一樣。 

這時 classesIDs 就方便多了。 一旦您定義了 class 或 ID,您可以連結到任何一個 HTML 標籤中使用,不管這個標籤原本有什麼特色。 

定義 class 的方法是取一個體裁元件的名稱(名稱之前加一個點) 然後加上體裁定義的屬性及內含值在大括號中就可以了:

.periwinkle { color: #6699ff}

一旦這個體裁元件加到了 HTML 文件之中 (參閱 應用在文件中), 您可以這樣子加到 HTML 標籤中使用:

<STRONG class="periwinkle">粗體水藍色的文字</STRONG> 

這就比單單使用 <STRONG> 標籤來的多樣化,前面的指令例子可以使 strong 標籤文字 periwinkle. 

IDs 基本上使用方法相同,除了前置符號是 (#) 以外 : 

#bright { font-weight: bolder; color: #00ff00 } 

加到 HTML 標籤中像是:

<P id="bright">這段文字不易閱讀</P>

使用 ID 像是給體裁元件一個專用的名稱, 當您使用描述檔(script files)時,會變的很有用 (您無需各別指定每個元件)但是您要 But if you're sure you'll be sticking with style sheets and not venturing into scripting, 一般則是用 classes 來作為體裁元件 

上一頁:連結外部定義檔 下一頁:特殊的定義方式

以下為文章回應區

同意轉載,不過麻煩看一下轉載需知

Shona   2017/11/17 上午 04:23:00

Hello There. I found your blog using msn. This is a very well written article.

I'll be sure to bookmark it and come back to read more of your useful information. Thanks for the post.

I will certainly comeback.

Lélio Vieira Carneiro Junio   2017/11/13 下午 06:22:00

You could definitely see your enthusiasm in the work you write.
The arena hopes for more passionate writers such as you who aren't afraid
to say how they believe. All the time go after your heart.

resort asbestos   2017/11/11 上午 05:44:00

Keep this going please, great job!

lilitavallaie.com   2017/11/11 上午 12:05:00

Appreciation to my father who informed me regarding this website, this weblog is actually
awesome.

Lelio Vieira Carneiro Junior   2017/11/10 上午 08:35:00

My partner and I absolutely love your blog and find nearly all of your post's to be just what I'm looking for.
Does one offer guest writers to write content for yourself?
I wouldn't mind creating a post or elaborating on some of the subjects you write about here.

Again, awesome site!

What is the tendon at the back of your ankle?   2017/9/25 下午 04:16:00

Definitely believe that which you said. Your favorite reason seemed to be on the net
the simplest thing to be aware of. I say to you,
I definitely get annoyed while people consider worries that they just don't know
about. You managed to hit the nail upon the top and defined out the whole thing without having side-effects , people could take a signal.
Will likely be back to get more. Thanks

How do I stretch my Achilles tendon?   2017/9/23 上午 06:55:00

An intriguing discussion is definitely worth comment. I believe that you
should write more on this subject matter, it may not be a
taboo matter but usually people do not discuss these issues.
To the next! All the best!!

Can stretching help you grow taller?   2017/8/21 下午 05:12:00

I read this piece of writing completely on the topic of the resemblance of most recent and previous technologies, it's remarkable article.

How do you get taller in a day?   2017/7/28 下午 09:42:00

Outstanding quest there. What happened after?
Thanks!

What causes pain in the Achilles tendon?   2017/7/27 下午 10:58:00

It is perfect time to make some plans for the future and it's time to be happy.
I've learn this put up and if I may just I want to suggest
you some fascinating things or tips. Maybe
you can write next articles relating to this article.
I desire to learn even more things about it!

What is distraction osteogenesis?   2017/7/22 下午 09:38:00

I loved as much as you will receive carried out right here.
The sketch is tasteful, your authored subject matter stylish.
nonetheless, you command get bought an shakiness over that you wish be delivering
the following. unwell unquestionably come more formerly again as exactly the same nearly a lot often inside case you shield this hike.

Can you get an operation to make you taller?   2017/7/15 下午 08:15:00

I take pleasure in, cause I discovered just what I was taking a look for.
You have ended my 4 day lengthy hunt! God Bless you man. Have a great
day. Bye

vitamin d overdose foot pain   2017/7/2 下午 03:20:00

You can definitely see your expertise within the work you write.
The world hopes for more passionate writers like you who aren't afraid to mention how they believe.
At all times follow your heart.

[ آدرس وبسايت ]   2017/6/24 下午 07:29:00

Hello, Neat post. There is a problem together with your web site in web explorer,
might check this? IE still is the marketplace chief and a big portion of people will leave out your magnificent writing because of this problem.

foot pain and swelling   2017/6/21 下午 03:58:00

Thanks for finally talking about >【卜維丰】定義語法 <Loved it!

rosannaarboleda.soup.io   2017/5/19 上午 06:02:00

Hello, I enjoy reading all of your post.
I like to write a little comment to support
you.

manicure   2017/5/4 上午 06:31:00

Wonderful goods from you, man. I have understand your stuff previous
to and you're just extremely great. I really like what you have acquired here, really like what you are stating and the way in which you say it.

You make it entertaining and you still care for to keep it
smart. I cant wait to read much more from you.
This is actually a terrific site.

BHW   2017/4/13 下午 11:28:00

Hi! This is my 1st comment here so I just wanted to give a quick shout out and say I genuinely
enjoy reading your articles. Can you recommend any other blogs/websites/forums
that go over the same subjects? Many thanks!

給個回應
姓名:
佈落格網址:
  如果您是要發問問題, 最好有個問題測試的網址, 這樣比較容易找到您問題所在, 謝謝
內容: