2017-07-24 66 views
0

我想在btn和txtbox之間添加一個新行,但沒有任何工作。我試過

和\ n在表格數據中添加換行符html

它表現爲: enter image description here

我的代碼:

<td> 
<div> 
<a class="btn btn-default pull-left" style="color: inherit" id="btn">my button</a> 
</div> 
<div> 
<input id="mytxt" > 
</div> 
</td> 
+0

喜你能使用段落


Keenlearner

+0

嘗試過,並沒有工作 – SMH

+0

即使
? – Keenlearner

回答

0

只需添加CSS樣式填充在頭:

<head> 
<title>Page Title</title> 
<style> 
#btn-div { 
padding-bottom: 20px; 
} 
</style> 
</head> 
<body> 

<td> 
<div id="btn-div"> 
<a class="btn btn-default pull-left" style="color: inherit" id="btn">my 
button</a> 
</div> 
<div> 
<input id="mytxt" > 
</div> 
</td> 
</body> 
+0

謝謝你,但這將改變頁面中的所有div,我不希望這種情況發生 – SMH

+0

@SMH然後添加一個CSS類到您要修改的div – Kai

+0

@SMH只更新了代碼,以便CSS僅應用於div的特定ID。 – Tim1234

2

這之中的HTML,你最好的選擇是,要麼添加一些CSS以提高利潤率/填充在第一個div的底部或第二個的頂部。或者,您可以在兩者之間添加一個空的div並將您的樣式應用於該樣式。

+0

嘗試了空的div,它不起作用 – SMH

0
  1. 你可以試試代碼之間插入。

    <p>&nbsp;</p> 
    
  2. 此外,您還可以嘗試

    <br /> 
    
  3. 我最喜歡的,做一個CSS文件

    <html> 
    <head> 
        <style> 
         .gap-10 { 
          width:100%; 
          height:10px; 
         } 
         .gap-20 { 
          width:100%; 
          height:20px; 
         } 
         .gap-30 { 
          width:100%; 
          height:30px; 
         } 
        </style> 
    </head> 
    <body> 
    
        <!-- this div will give a gap of 10px --> 
        <div class="gap-10"></div> 
    
        <!-- this div will give a gap of 20px --> 
        <div class="gap-20"></div> 
    
        <!-- this div will give a gap of 30px --> 
        <div class="gap-30"></div> 
    
    </body> 
    

    我希望它能幫助