html - css 如何讓文字標(biāo)題顯示在邊框上?
問題描述
如圖,如何讓文字標(biāo)題顯示在邊框上?
問題解答
回答1:<fieldset> <legend>【使用方法】</legend> </fieldset>回答2:
如果需要更精確的擴(kuò)展,fieldset的效果不好,還自己實現(xiàn)一個吧,如下:
<style> .box{position:relative;border:1px solid red; } .box::before{content:attr(title);position:absolute;left:50%;transform:translateX(-50%);-webkit-transform:translate(-50%,-50%);padding:0 10px;background-color:#fff; }</style><p > <ol><li>這是啥</li><li>干啥</li> </ol></p>回答3:
<!DOCTYPE html><html lang='en'><head> <meta charset='UTF-8'> <title>Title</title></head><body><fieldset> <legend style='text-align: center'>【使用方法】</legend></fieldset></body></html>回答4:
提供一種hacked方法:
style:
p { width: 400px; height: 200px; border: 1px solid #ccc; } p h1 { height: 20px; margin: -10px auto 0; font-size: 14px; padding: 0 10px; text-align: center; width: 50px; }
html:
<p> <h1>嘿嘿嘿</h1> </p>回答5:
隨便想了一下,湊合著用吧http://codepen.io/colahan/pen...
不太建議使用fieldset,一般都會被reset的
回答6:絕對定位加文字定寬高
回答7:很明顯是絕對定位呀
回答8:<style> h2:before, h2:after {content: '';display: inline-block;vertical-align:middle;width: 100px;border-top: 1px solid #123456; }</style><h2>線標(biāo)題</h2>
相關(guān)文章:
1. 視頻文件不能播放,怎么辦?2. node.js - nodejs開發(fā)中常用的連接mysql的庫3. mysql replace 死鎖4. phpstudy pro小皮面板經(jīng)常報這個nginx: [emerg] CreateFile【急】5. 老師您的微信號是多少?6. mysql - 把一個表中的數(shù)據(jù)count更新到另一個表里?7. mysql - 分庫分表、分區(qū)、讀寫分離 這些都是用在什么場景下 ,會帶來哪些效率或者其他方面的好處8. 請教使用PDO連接MSSQL數(shù)據(jù)庫插入是亂碼問題?9. 雙擊安裝程序,安裝不了10. mysql - 字符串根據(jù)字典替換
