2012-09-21 57 views
0

我一直給這個佈局,我有一個部分,有一些信息。 但是,在視覺上,該部分的屏幕寬度爲100%,而內容僅爲70%。HTML5部分 - 如何在這種情況下標記和樣式?

風格是內聯的澄清提出:

問題1 - 這是一個可以接受的標記?

<section> 
    <div class="row-red" style="width=100%; background-color: red;"> 
    <h1 style="width:70%">section header here</h1> 
    <p style="width:70%">paragraph 1</p> 
    </div> 
    <div class="row-blue" style="width: 100%; background-color: blue;"> 
    <p style="width:70%">paragraph 2</p> 
    </div> 
</section> 

在此先感謝

下面是來自小提琴採取一個例子就寫到這裏了首位:

http://jsfiddle.net/gSLww/9/

+0

你有這個實際效果的一個例子嗎?一個jsfiddle也許? –

+3

@KyleSevenoaks:他從來沒有說過他們需要水平堆疊。 –

+0

這是一個相當主觀的問題,但就純語義標記而言,我認爲你已經選擇了一個完全可以接受的解決方案。 –

回答

0

是的,這是一個可以接受的標記,但只有你有去努力它的CSS。像這樣寫:

.row-red,.row-blue{ 
    padding-right:30% 
} 

HTML

<section> 
    <div class="row-red" style="background-color: red;"> 
    <h1>section header here</h1> 
    <p>paragraph 1</p> 
    </div> 
    <div class="row-blue" style="background-color: blue;"> 
    <p>paragraph 2</p> 
    </div> 
</section> 

入住這http://jsfiddle.net/gSLww/15/