JSFiddle - React, Tailwind, and code Playground
HTML
<div id="sidebar">
<h3 class="widget_title">テキスト</h3>
<p>
何かしらのテキスト 何かしらのテキスト 何かしらのテキスト 何かしらのテキスト 何かしらのテキスト 何かしらのテキスト 何かしらのテキスト 何かしらのテキスト 何かしらのテキスト 何かしらのテキスト 何かしらのテキスト 何かしらのテキスト 何かしらのテキスト
</p>
</div>
CSS
#sidebar .widget_title {
display: block;
margin: 10px auto;
padding: 0;
color: #fff;
font-size: 18px;
border-bottom: 2px solid #289dcc;
}
#sidebar .widget_title span {
padding: 0 6px;
background-color: #289dcc;
}
/*不要*/
#sidebar {
width: 300px;
float: right;
}
JavaScript
(function($){
$(function(){
$("#sidebar").find(".widget_title").each(function(){
var text = $(this).text();
$(this).empty().append("<span>"+text+"</span>");
});
});
})(jQuery);