This is probably a basic html/css question...
這可能是一個基本的html/css問題……
I have a simple one-button form that I would like to display inline inside paragraph text.
我有一個簡單的單按鈕表單,我想在段落文本內顯示。
Read this sentence
type='submit'
value='or push this button'/>
.Even though form has style=display:inline attribute, I get a linebreak before the form. Is there a way to get rid of it?
盡管表單具有style=display:inline屬性,但我在表單之前獲得了換行符。有辦法擺脫它嗎?
Can form elements appear inside
?
表單元素可以出現在
中嗎?
6 个解决方案
#1
71
Move your form tag just outside the paragraph and set margins / padding to zero:
將表單標記移到段落外,並將頁邊距/填充設置為0:
Read this sentence
#2
52
cannot go inside, no. The browser is going to abruptly close your
element when it hits the opening
tag as it tries to handle what it thinks is an unclosed paragraph element:不能進入
, no。瀏覽器會突然關閉
元素,當它點擊開始的標簽時,它試圖處理它認為是未關閉段落的元素:
Read this sentence
#3
19
You can try this code:
您可以試試下面的代碼:
User:
Password:
The important thing to note is the css style property in the
tag.需要注意的是
標記中的css style屬性。
display:inline!important;
顯示:內聯!重要;
#4
6
According to HTML spec both
andare block elements and you cannot nest them. Maybe replacing the
with would work for you?
根據HTML規范,
和
都是塊元素,不能嵌套。也許用替換
對你有用嗎?
EDIT: Sorry. I was to quick in my wording. The
element doesn't allow any block content within - as specified by HTML spec for paragraphs.
編輯:對不起。我的措詞很快。
元素不允許任何塊內容-如HTML規范為段落指定的那樣。
#5
0
You can accomplish what you want, I think, simply by including the submit button within the paragraph:
我認為,只要在段落中包含submit按鈕,就可以實現您想要的內容:
Read this sentence
#6
0
Just use the style float: left in this way:
使用樣式float:左:
Lorem Ipsum
Lorem Ipsum