for (i=1; i <= 3; i++) {
var larg = $("parallax-section-" + i).find('.testo-parallax').width();
var largPa = larg / 2;
var largParallax = "-" + largPa;
$("parallax-section-" + i).find('.testo-parallax').css("margin-left", largParallax);
}
HTML
<section class="slide parallax-section-2" >
<h6 class="testo-parallax">Il weeb asdf asss dasdf ss.</h6>
</section>
CSS
.testo-parallax {
font-size: 80px;
color: #fff;
font-weight: 600;
position: absolute;
top: 50%;
left:50%;
margin:0;
padding:0;
margin-top: -40px;
}
我想从左边的文本(.testo-parallax)开始居中(.parallax-section)。我有三个部分,我想检查宽度,以获得半宽的边距 - 左和 -