2012-01-12 24 views
1

我熟悉帶有=「my_id」標籤和輸入類型標籤的樣式表單。我真的很喜歡它如何自動設置窗體組件的樣式,如果窗體寬度下降到更窄的寬度,我喜歡輸入標籤左對齊。在jquery mobile中設置樣式標籤和值的建議方法是什麼?

我想做相同類型的樣式,除了現在我想要顯示一個記錄,其中標籤和它們的值被類似地設置樣式。

這裏有一些代碼,我希望能夠工作,但事實並非如此。

<div data-role="fieldcontain"> 
    <label for="full_name"><strong>Name:</strong></label> 
    <span id="full_name">John Smith</span> 
</div> 
<div data-role="fieldcontain"> 
    <label for="phone"><strong>Long Phone Label:</strong></label> 
    <span id="phone">(800) 555-1212/span> 
</div> 

正確的方式做到這一點,而不訴諸表的任何想法?

+0

我不明白你在問什麼。什麼「自動設置表單組件」?你指的是哪種「相同類型的造型」? 「風格類似」到什麼?此外,我懷疑你應該/可以使用這樣的標籤。標籤'for'屬性應該引用表單控件不跨越。你爲什麼不能用桌子?這看起來就像正確使用表格的一個主要例子。 – RoToRa 2012-01-12 12:26:49

回答

0
It seems that you want to align the text in the way the form is aligned.The below code will align the labels with their values.This is what i understand from your question.i hope the below code will help you. 

<!DOCTYPE html> 
<html> 
<head> 
<link rel="stylesheet" href="jquery.mobile-1.0rc1.css" /> 
<script type="text/javascript" src="js/Common/jquery-1.6.2.min.js"></script> 
<script type="text/javascript" src="js/Common/jquery.mobile-1.0rc1.js"></script> 

<style> 
#b { 
    left: 156px; 
    bottom: 50px; 
} 

</style> 
</head> 
<body> 
<div data-role="page" id="header"> 
    <div data-role="fieldcontain" id="a"> 
    <label for="full_name"><strong>Name:</strong></label><br> 
    <label for="phone"><strong>Long Phone Label:</strong></label> 
</div> 
<div data-role="fieldcontain" id="b"> 
    <span id="full_name">John Smith</span><br> 
    <span id="phone">(800) 555-1212</span> 
</div> 
</div> 
</body> 
</html> 
+0

感謝您的回覆。你提供的解決方案並不按我想要的方式工作。它在內容上方顯示名稱和電話標籤。我希望名稱:約翰史密斯,然後在下一行Long Phone Label:(800)555-1212。我希望這是有道理的。 – noctufaber 2012-01-12 15:33:23

0

也許這會奏效。你可以使用一個JQM電網並排標籤做一個側面:

標籤:輸入元素 標籤:輸入元素

不過要小心爲移動標籤都是這樣的目的。這是你可以看到標籤和輸入時,像一個像Ihone設備:

<div class="ui-grid-a"> 
<div class="ui-block-a"><strong>I'm Block A</strong> and text inside will wrap</div> 
<div class="ui-block-b"><strong>I'm Block B</strong> and text inside will wrap</div> 
</div> 
相關問題