顯示頁面舊版反向連結Copy this pageExport to Markdown輸出PDF檔案Fold/unfold allNew PageNew Folder回到頁頂Add Tags 本頁是唯讀的,您可以看到原始碼,但不能更動它。您如果覺得它不應被鎖上,請詢問管理員。 ====== 開發 fieldset plugin ====== 覺得<html><fieldset><legend>像這樣的</legend></html>fieldset 蠻好用的 <html></fieldset></html>(應該要用一般瀏覽器常見的 style,legend 的文字在邊線左上角),而不是用各 DW tpl 自己的樣式),但當然不可能每次都打一堆 HTML 碼:<code><html><fieldset><legend>像這樣的</legend></html>fieldset 蠻好用的 <html></fieldset></html></code> 考慮兩種解法:<div list-tree> * 做專屬的 syntax plugin * 用 wrap div/span + CSS </div> ===== plugin ===== 因為不同的 DW tpl 各有不同的 fieldset、legend CSS,所以本來我想就不做 plugin 了,用下面的純 wrap+CSS 法就好。但後來又想,我也可以弄 plugin,但產生 ''div.fieldset'' 之類的啊。所以就再次來挑戰看看 syntax plugin 吧(雖然之前從來沒成功)。 - 試著用 [[doku>plugin:ruby]] 來改 - 開 repo - 其實語法有頭有尾 ∴也應該參考 wrap 才是 ← 想到就難,先休息好了 <<哈>> ==== 參考 ==== * [[https://www.dokuwiki.org/devel:syntax_plugin_skeleton|devel:syntax_plugin_skeleton [DokuWiki]]] ===== CSS ===== 一般瀏覽器常見的 legend style 到底是怎樣? * [[https://html.spec.whatwg.org/multipage/rendering.html#the-fieldset-and-legend-elements|HTML Standard]] 這裡面的 CSS 似乎不是,至少在 BlueGriffon 裡套到 ''div.fieldset''、''div.legend'' 上的話還是無法呈現我要的效果 * 用 Waterfox 網頁開發者工具挖出 fieldset 及 legend 的「瀏覽器樣式」,再套到測試的網頁 CSS 裡,也無效 擬真: * [[https://stackoverflow.com/questions/2213881/is-it-possible-to-achieve-a-fieldset-like-effect-without-using-the-fieldset#answer-2214676|html - Is it possible to achieve a <fieldset>-like effect without using the <fieldset> tag? - Stack Overflow]] 這位提出來的 CSS 效果還不錯 * 我在一般網頁實測過也還 okay,就是要多用一個 span 就是了 * <todo #ghsrobert:2020-10-28>在 DW 中實測</todo><code css> .wrap_fieldset { border: 2px groove threedface; border-top: none; padding: 0.5em; margin: 1em 2px; } .wrap_fieldset>.wrap_legend { font: 1em normal; margin: -1em -0.5em 0; } .wrap_fieldset>.wrap_legend>p { float: left; } .wrap_fieldset>.wrap_legend:before { border-top: 2px groove threedface; content: ' '; float: left; margin: 0.5em 2px 0 -1px; width: 0.75em; } .wrap_fieldset>.wrap_legend:after { border-top: 2px groove threedface; content: ' '; display: block; height: 1.5em; left: 2px; margin: 0 1px 0 0; overflow: hidden; position: relative; top: 0.5em; } </code>可以看到我把原作者的 span 改成了 p,因為 wrap plugin 本身就會產生 p,這樣少一道輸入。結果:<div> <div fieldset><div legend>標題</div> 內容 </div> </div><code> <div fieldset><div legend>標題</div> 內容 </div> </code> * 在主站勉強可以(內容的位置會往右縮排,不知何故) * 在 mikio tpl 中,legend 的位置就跑掉了 * ↑<code css>.wrap_fieldset>.wrap_legend>p { margin-top: 0; margin-bottom: 0; }</code>↑加上這兩行的話可以解決 legend p 的高度,以及因為 float 而影響內容位置的問題 :) 這樣可用性就提高了~ ==== 參考 ==== * [[https://www.google.com/search?q=css+style+like+fieldset+legend|css style like fieldset legend - Google 搜尋]] 上一次變更: 2020/10/30 00:02由 ghsrobert