====== 開發 fieldset plugin ====== 覺得
像這樣的fieldset 蠻好用的
(應該要用一般瀏覽器常見的 style,legend 的文字在邊線左上角),而不是用各 DW tpl 自己的樣式),但當然不可能每次都打一堆 HTML 碼:
像這樣的fieldset 蠻好用的
考慮兩種解法:
* 做專屬的 syntax plugin * 用 wrap div/span + CSS
===== 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
-like effect without using the
tag? - Stack Overflow]] 這位提出來的 CSS 效果還不錯 * 我在一般網頁實測過也還 okay,就是要多用一個 span 就是了 * 在 DW 中實測 .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; } 可以看到我把原作者的 span 改成了 p,因為 wrap plugin 本身就會產生 p,這樣少一道輸入。結果:
標題
內容
標題
內容
* 在主站勉強可以(內容的位置會往右縮排,不知何故) * 在 mikio tpl 中,legend 的位置就跑掉了 * ↑.wrap_fieldset>.wrap_legend>p { margin-top: 0; margin-bottom: 0; }↑加上這兩行的話可以解決 legend p 的高度,以及因為 float 而影響內容位置的問題 :) 這樣可用性就提高了~ ==== 參考 ==== * [[https://www.google.com/search?q=css+style+like+fieldset+legend|css style like fieldset legend - Google 搜尋]]