我想"画"带CSS的可缩放平方根符号;我目前的尝试是:
.root {
display: inline-block;
vertical-align: middle;
}
.radix1 {
display: inline-block;
width: 0.2em;
height: 1.5ex;
vertical-align: bottom;
border-top: 0.2ex solid;
border-right: 0.15ex solid;
transform: skew(25deg);
}
.radix2 {
display: inline-block;
vertical-align: bottom;
border-top: 0.2ex solid;
border-left: 0.15ex solid;
transform: skew(-15deg);
}
.radicand {
display: inline-block;
padding-left: 0.5em;
transform: skew(15deg);
}

<p>Lore ipsum
<span class="root">
<span class="radix1"></span>
<span class="radix2">
<span class="radicand">
2<var>xy</var>
</span>
</span>
</span>
lore ipsum.</p>
<p>Lore ipsum
<span class="root">
<span class="radix1"></span>
<span class="radix2">
<span class="radicand">
2<var>x y</var><br />2<var>pq</var>
</span>
</span>
</span>
lore ipsum.</p>
<p>Lore ipsum
<span class="root">
<span class="radix1"></span>
<span class="radix2">
<span class="radicand">
2<var>xy</var><br />2<var>pq</var><br />123,456,789
</span>
</span>
</span>
lore ipsum.</p>
&#13;
(示例2和3中的换行符只是对较大参数(如分数,矩阵等)的简单替换。) 我的问题和愿望清单是:
答案 0 :(得分:2)
您可以尝试使用一个元素来创建根方块。然后对小部件使用伪元素,以便您可以轻松调整其相对于主要部分的位置。
.root {
display: inline-block;
vertical-align: middle;
border-top: 1px solid;
border-left: 1px solid;
transform: skew(-15deg);
transform-origin: bottom left;
margin: 0 10px;
position: relative;
}
.root:before {
content: "";
position: absolute;
bottom: 0;
height: 40%;
width: 5px;
left: -5px;
border-top: 1px solid;
border-right: 1px solid;
transform: skew(30deg);
transform-origin: bottom right;
}
.radicand {
display: inline-block;
padding-left: 0.5em;
transform: skew(15deg);
}
&#13;
<p>Lore ipsum
<span class="root">
<span class="radicand">
2<var>xy</var>
</span></span> lore ipsum.</p>
<p>Lore ipsum
<span class="root">
<span class="radicand">
2<var>x y</var><br>2<var>pq</var>
</span> </span> lore ipsum.</p>
<p>Lore ipsum
<span class="root">
<span class="radicand">
2<var>xy</var><br>2<var>pq</var><br>123,456,789
</span> </span>lore ipsum.</p>
&#13;