2017-07-28 76 views
1

藍色表格數據條目不會存在其寬度。有沒有一種新的html5方法能夠實現這一壯舉?該行應該與上面的照片具有相同的寬度。無法更改表格的寬度<TD>

<div class="template" style="text-align:center"> 
 
    <table width="100%" and height="100%" BORDER=0 CELLSPACING=0 CELLPADDING=0 align="center"> 
 
\t \t <tr> 
 
\t \t \t <td width='100%' height='100%' bgcolor='#f2f3f4'> 
 
\t \t \t \t <div style="text-align: center;"> 
 
\t \t \t \t \t \t <img src ="https://image.ibb.co/i4ykZk/roverlogo.png" alt="RoverLogo"> 
 
\t \t \t \t </div> 
 
\t \t \t </td> 
 
\t \t </tr> 
 
\t 
 
<!-- Background photo --> 
 

 
\t <TABLE width="80%" BORDER="0" cellpadding="0" CELLSPACING="0" align="center"> 
 
\t <TR> 
 

 
\t  <TD WIDTH="997" HEIGHT="326" 
 
     background="https://image.ibb.co/dO1HfQ/dog3edit.jpg" style="background- 
 
     image:url(https://image.ibb.co/dO1HfQ/dog3edit.jpg); background-repeat: 
 
     no-repeat;"> 
 

 
\t <!-- <b>WELCOME TO ROVER! </b> --> 
 
\t <FONT class="titletext" color="white" align="center" style="width: 800px; 
 
\t font-size: 50px;"><b>WELCOME TO ROVER!</b></FONT><br><br> 
 
\t <FONT class="subtitletext" color="white" align="center" style="width: 
 
     100px; 
 
\t font-size: 30px;">Ready to get started?</FONT><br><br><br> 
 
\t 
 
\t <a href="#"><img src="https://image.ibb.co/nvbiLQ/button.png" 
 
     alt="Button" border="0"></a> 
 
\t 
 
\t </TD> 
 

 
\t </TR> 
 
\t <tr> 
 
\t  <td width="80%" bgcolor="#blue" style="width:80%"> 
 
\t  </td> 
 
\t </tr> 
 
\t </TABLE> 
 
    </table> 
 
    </div>

+1

我不認爲你想在這裏的表。用於創建佈局時,表格在語義上並不正確。利用CSS。這將是HTML5的方式。 – kauffee000

+1

我創建的佈局將用作電子郵件模板。電子郵件有不同的「語義正確」意義,但你會使用什麼樣的CSS?我試過使用內聯CSS,它似乎沒有工作。 –

+0

我在下面更新了我的答案。 – kauffee000

回答

1

article { 
 
    width: 100%; 
 
} 
 

 
#banner { 
 
    background: url("https://image.ibb.co/dO1HfQ/dog3edit.jpg") no-repeat no-repeat; 
 
    padding: 25px 0; 
 
} 
 

 
h1 { 
 
    font-size: 50px; 
 
    margin-bottom: 0; 
 
} 
 

 
h1, p { 
 
    color: white; 
 
    width: 100%; 
 
    text-align: center; 
 
} 
 

 
p { 
 
    font-size: 30px; 
 
} 
 

 
button { 
 
    width: 200px; 
 
    background: #00c55c; 
 
    border: none; 
 
    padding: 12px 24px; 
 
    color: white; 
 
    font-size: 24px; 
 
    border-radius: 6px; 
 
    display: block; 
 
    margin: 0 auto; 
 
    clear: both; 
 
} 
 

 
#logo { 
 
    background: #f2f3f4; 
 
} 
 

 
#logo img { 
 
    display: block; 
 
    margin: 0 auto; 
 
    clear: both; 
 
}
<article> 
 
    
 
    <section id="logo"> 
 
     <img src ="https://image.ibb.co/i4ykZk/roverlogo.png" alt="RoverLogo"> 
 
    </section> \t  
 
    
 
    <section id="banner"> 
 
     
 
     <h1>Welcome to Rover!</h1> 
 
     <p>Ready to get started?</p> 
 
     <button>Search Sitters</button> 
 
    
 
    </section> 
 
    
 
</article>

我做事端像這樣。沒有佈局表格。如果必須內聯,只需在HTML塊上方放置一個<style></style>標籤即可。

+1

這將是一個網頁的理想解決方案。不幸的是,大多數電子郵件服務器會阻止電子郵件中的「正文」部分,所以我使用100%w/h的表格來獲取電子郵件的背景顏色。背景顏色假設爲灰色。 –

+0

我設置了文章元素的寬度。沒有更多的身體標籤。 – kauffee000

0

您使用內聯CSS,試試這個:

<TABLE style="width="80%" BORDER="0" cellpadding="0" CELLSPACING="0" align="center"";>

1

對於我使用以下網站的按鈕的背景顏色。

https://flatuicolors.com/

我還做了一切分成CSS和HTML,所以你可以看到的。沒有內聯CSS。這是使用表格和標題的正確方法。

爲標頭使用<div>標籤,因爲它會自動將東西推到後面的新行。不需要中斷標籤。中斷標籤很少用於設計中。

另外我確定你的分隔線是藍色的。

我相信有沒有更好的方式來完成這個沒有表,但是你說你需要這個表格形式,所以在這裏你去!

table { 
 
    width: 80%; 
 
    border: none; 
 
    text-align: center; 
 
    margin: 0 auto; 
 
    color: white; 
 
} 
 

 
.background { 
 
background: url('https://image.ibb.co/dO1HfQ/dog3edit.jpg'); 
 
} 
 
.titletext { 
 
    font-size: 50px; 
 
} 
 

 
.subtitletext { 
 
    font-size: 30px; 
 
} 
 

 
button { 
 
    margin: 10px 0; 
 
    width: 50%; 
 
    border-radius: 15px; 
 
    height: 100px; 
 
    background: #27ae60; 
 
    border: 1px solid rgba(255,255,255,0.8); 
 
    font-size: 20px; 
 
    color: white; 
 
} 
 

 
button:hover { 
 
    background-color: #2ecc71; 
 
} 
 

 

 
.seperator { 
 
    width: 80%; 
 
    background: blue; 
 
}
<TABLE> 
 
    <TR class="background"> 
 
    <TD> 
 
     <div class="titletext">WELCOME TO ROVER!</div> 
 
     <div class="subtitletext">Ready to get started?</div> 
 
     <a href="#"><button>Search Sitters</button></a> 
 
    </TD> 
 
    </TR> 
 
    <tr> 
 
    <td class="seperator""></td> 
 
    </tr> 
 
</TABLE>

+0

我目前有一個表內的表,並需要在style屬性中使用內聯CSS。有沒有辦法爲多個表定義css? –

+0

在表格標籤中使用一個ID。 '

'...然後使用CSS'#tablename'中的id選擇器來選擇該表。如果使用內聯CSS,只需使用style屬性即可。 '
' –

+0

@RossRhone如果您發現此信息有幫助,請將其標記爲答案。不要忘記註冊! –