JSFiddle - React, Tailwind, and code Playground
HTML
<div id="sidebar">
<h3 class="widget_title">テキスト</h3>
<p>
何かしらのテキスト 何かしらのテキスト 何かしらのテキスト 何かしらのテキスト 何かしらのテキスト 何かしらのテキスト 何かしらのテキスト 何かしらのテキスト 何かしらのテキスト 何かしらのテキスト 何かしらのテキスト 何かしらのテキスト 何かしらのテキスト
</p>
<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;
overflow: hidden;
}
#sidebar .widget_title span {
display: inline-block;
padding: 0 6px;
background-color: #289dcc;
opacity: 0;
visibility: hidden;
transition: .6s ease;
-webkit-transform: translate(0, 200%);
transform: translate(0, 200%);
}
#sidebar .widget_title.show span {
opacity: 1;
visibility: visible;
-webkit-transform: translate(0, 0);
transform: translate(0, 0);
}
/*不要*/
#sidebar {
width: 300px;
float: right;
}
JavaScript
(function($) {
var loadedshow = function(){
var d = $.Deferred();
$("#sidebar").find(".widget_title").each(function() {
var text = $(this).text();
$(this).empty().append("<span>" + text + "</span>");
return d.resolve();
});
return d.promise();
};
$(window).on("load", function() {
loadedshow().then(function(){
$("#sidebar").find(".widget_title").each(function(){
$(this).addClass("show");
});
});
});
})(jQuery);