[英]How do I center a div element with typed.js
How do I center a div element with typed.js如何使用 typed.js 使 div 元素居中
<script>
var typed = new Typed('#typed', {
stringsElement: '#typed-strings'
});
</script>
<script>
document.addEventListener('DOMContentLoaded', function() { var typed = new Typed("#typed", { stringsElement:'#typed-strings', typeSpeed: 30, }); });
</script>
<br><br>
<div id="typed-strings">
<p>
text here</p>
</div>
<div id="typed"></div>
I tried to use css to center my div where the text is being typed:我尝试使用 css 将我的 div 置于输入文本的中心:
#typed-strings {
top: 50%;
left: 50%;
border: 4px solid #ecf0f1;
}
If you're looking to center the typed text inside the div:如果您希望将输入的文本居中放置在 div 中:
#typed-strings {
text-align: center;
}
If you're looking to center the div in the center of the screen:如果您希望将 div 置于屏幕中央:
#typed-strings {
width: 500px;
margin: auto 0;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.