我想在contenteditable区域中的已编辑文本之前和之后添加空格,例如之前和之后的一个空格,那么我如何使用CSS做到这一点。这是我的脚本:jsfiddle
[contenteditable="true"] {
background-color: DodgerBlue;
}
[contenteditable="true"]:focus {
background-color: white;
color : black;
}
span.a {
border: 1px solid white;
}
span.a:empty {
padding-right:10px;
}
Lorem Ipsum is simply dummy text of the printing and typesetting industry.
Lorem Ipsum has been the industry's standard dummy text ever since the 1500s,
<span class="a" contenteditable="true">
when an unknown printer
</span> took a galley of type and scrambled it to make a type specimen book.
It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged.
It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages,
and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
答案 0 :(得分:0)
您可以添加以下内容:
[contenteditable="true"] {
margin: 0 5px 0;
}
这将在contenteditable区域的两侧增加间距。
[contenteditable="true"] {
background-color: DodgerBlue;
}
[contenteditable="true"]:focus {
background-color: white;
color : black;
}
[contenteditable="true"] {
margin: 0 5px 0;
}
span.a {
border: 1px solid white;
}
span.a:empty {
padding-right:10px;
}
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, <span class="a" contenteditable="true">when an unknown printer</span> took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.