2011-03-07 13 views
36

我可以這樣做的HTML:頂端提供邊境稱號DIV

我想在我的div添加邊框標題(「基本信息」此圖像中)。可能嗎?怎麼做?


注:
圖像不HTML頁面的圖像,它的Java應用程序的形象。

回答

46
<div id="form" style="width:350px;"> 
    <fieldset> 
     <legend style="color:blue;font-weight:bold;">General Information</legend> 
     <table> 
     <tr> 
      <td><span style="text-decoration:underline">C</span>hange Password To:</td> 
      <td><input type="text"/></td> 
     </tr> 
     <tr> 
      <td><span style="text-decoration:underline">C</span>onfirm Password:</td> 
      <td><input type="text"/></td> 
     </tr> 
     </table> 
    </fieldset> 
</div> 
+2

使用fieldset作爲邊界在語義上是否正確?我在想。 – gamov 2012-10-10 04:00:41

+0

Plnkr鏈接http://plnkr.co/edit/LpHRzFpEUz2BC5ZN2Q07?p=preview – Abhijeet 2015-06-27 11:12:57

11

的圖像可能使用fieldset標籤,而不是div,一個fieldset裏面你可以使用標籤legend,它會自動定位在那裏。

<fieldset> 
<legend>General Information</legend> 
</fieldset> 
+0

日Thnx,它不是一個HTML頁面的圖像。它是一個Java應用程序的圖像。 – 2011-03-07 05:10:21

+0

我明白了,也許你應該在問題中加上這一點。 – amosrivera 2011-03-07 05:13:59

2
<fieldset style="width:100px;"> 

<legend> 

Please Enter Your Name</legend> 

<br> 

<table> 

<tr> 

<td>First Name:</td> 

<td><input type="text" /></td> 

</tr> 

<tr> 

<td>Last Name:</td> 

<td><input type="text" /></td> 

</tr> 

</table> 

</fieldset> 

這將givu喜歡這款U輸出。

enter image description here

0

圓形邊框與背景顏色。

<!DOCTYPE html> 
<html> 
<head> 
<style> 
.sample 
{ 
border:2px solid #a1a1a1; 
padding:10px 40px; 
background:#dddddd; 
width:300px; 
border-radius:25px; 
} 
</style> 
</head> 
<body> 

<div class="sample"> 
The border-radius property allows you to add rounded corners to elements. 

<fieldset style="width:100px;"> 

<legend> 

Please Enter Your Name</legend> 

<br> 

<table> 

<tr> 

<td>First Name:</td> 

<td><input type="text" /></td> 

</tr> 

<tr> 

<td>Last Name:</td> 

<td><input type="text" /></td> 

</tr> 

<tr> 

<td>First Name:</td> 

<td><input type="text" /></td> 

</tr> 

<tr> 

<td>Last Name:</td> 

<td><input type="text" /></td> 

</tr> 

</table> 

<input type="submit" value="Submit"> 


</fieldset> 

</div> 
</body> 
</html> 

這會給這樣的輸出,

enter image description here