我正在試圖設計一個和cite
子元素來複制fieldset
和legend
元素的外觀,在該元素的外圍有一個邊框,並且圖例標籤位於邊框的頂部 - 如果您的「我看過一個字段,你會明白我的意思。如何將blockquote +引用爲表單fieldset + legend的樣式?
我有一個解決方案,我給cite
一個背景顏色,但這隻會在放在類似的彩色背景上時才起作用。 我需要一個解決方案,將所有的背景,BG圖像等IE8 +
假設下面的標記工作(不能從這個改變沒有額外的元素允許):
<blockquote class="quote">
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Voluptas rem, animi
facere illum deserunt nam ipsa, et sapiente quisquam sed repudiandae aliquam
delectus. Reiciendis repellat illo, et natus earum odit!
<cite class="attribution">Mr. Jefferson</cite>
</blockquote>
CSS我到目前爲止有:
.quote {
border: 4px solid black;
padding: 1rem;
position: relative;
}
.attribution {
position: absolute;
top: 0;
left: 1rem;
margin-top: -0.65rem;
padding: 0 1rem;
background: white; /* this works, but breaks if the background isn't white. I need a solution that works for all possible page bg colors */
}
這是我到目前爲止有:http://jsbin.com/viqegerivi/edit?html,css,output
沒有CSS的「繼承父背景顏色,除非家長有'transparent',在這種情況下,從其父繼承遞歸」,所以我恐怕你必須使用Javascript來做到這一點。 –
@MrLister這不是我要問的。我想讓它透明。背景顏色技術只是一個黑客。它應該複製fieldset/legend的行爲。使用背景顏色是我能得到的最接近的顏色,我特別不想使用bg顏色。 – Prefix
但問題是,當您使用透明時,父項的邊框在文本後面可見。你需要一個背景。 –