首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在Vue + Laravel项目中不能在div (水平和垂直)内对文本进行居中,同时保持它的响应性

在Vue + Laravel项目中不能在div (水平和垂直)内对文本进行居中,同时保持它的响应性
EN

Stack Overflow用户
提问于 2022-04-22 16:36:51
回答 2查看 129关注 0票数 -1

我试着把这篇文章放在纵向和横向的中心,但由于某种原因,它没有起作用。我发现的唯一解决方案是添加一组媒体查询,并根据屏幕大小调整页边距,但必须有更好的解决方案,在保持文本响应的同时居中。有什么建议吗?

代码语言:javascript
复制
<div class="row no-gutters">
                <div class="col-xs-12 p-0" style="background-color:#f2f2f2;">                    
                    <div class="col-xs-12 col-md-6 pt-1 px-5 text-description">
                        <h4 class="section-title text-left space-text" style="margin-bottom: 24px;text-transform: uppercase;">Pepe Calderin's Majestic Million Dollar Penthouse in Miami<div class="section-w-border"></div></h4>
                        <p style="text-transform: uppercase; color:#EC1B33;">Luxurious, Modern & Artistic</p>
                        <p>Famous for delivering unique design projects with high-end standards, Pepe Calderin partnered up with Essential Home, DelightFULL and Mid-Century Club to create the ultimate dream home that captures the heart of the popular city of Miami. This majestic luxury penthouse project presents us with design excellency, top-quality pieces, and an incredible view of one of the most luxurious marinas in the city.</p>
                        <p>Featuring a carefully chosen selection of costume furniture, bespoke lighting, and unique art pieces, this incredible modern penthouse design features 14 different experiences flowing throughout two floors on top of one of Miami's most luxurious skyscrapers. Don't miss out on the chance to discover this flamboyant design project that can also be seen as the ultimate dream home.</p>                        
                    </div>
                    <div class="col-xs-12 col-md-6 p-0">
                        <a class="swiper-anchor">
                            <img src="/images/campaigns/pepe-calderin/VIRTUALTOUR.jpg" alt="Karim Rashid House Chicago" class="img-responsive">                            
                        </a>                        
                    </div>
                </div>
            </div>

EN

回答 2

Stack Overflow用户

发布于 2022-04-22 16:53:03

如果需要,可以将样式内联为style=“文本对齐:中心”,也可以使用css。

代码语言:javascript
复制
.text-description {text-align:center;}
代码语言:javascript
复制
<div class="row no-gutters">
                <div class="col-xs-12 p-0" style="background-color:#f2f2f2;">                    
                    <div class="col-xs-12 col-md-6 pt-1 px-5 text-description" style="text-align:center">
                        <h4 class="section-title text-left space-text" style="margin-bottom: 24px;text-transform: uppercase;">Pepe Calderin's Majestic Million Dollar Penthouse in Miami<div class="section-w-border"></div></h4>
                        <p style="text-transform: uppercase; color:#EC1B33;">Luxurious, Modern & Artistic</p>
                        <p>Famous for delivering unique design projects with high-end standards, Pepe Calderin partnered up with Essential Home, DelightFULL and Mid-Century Club to create the ultimate dream home that captures the heart of the popular city of Miami. This majestic luxury penthouse project presents us with design excellency, top-quality pieces, and an incredible view of one of the most luxurious marinas in the city.</p>
                        <p>Featuring a carefully chosen selection of costume furniture, bespoke lighting, and unique art pieces, this incredible modern penthouse design features 14 different experiences flowing throughout two floors on top of one of Miami's most luxurious skyscrapers. Don't miss out on the chance to discover this flamboyant design project that can also be seen as the ultimate dream home.</p>                        
                    </div>
                    <div class="col-xs-12 col-md-6 p-0">
                        <a class="swiper-anchor">
                            <img src="/images/campaigns/pepe-calderin/VIRTUALTOUR.jpg" alt="Karim Rashid House Chicago" class="img-responsive">                            
                        </a>                        
                    </div>
                </div>
            </div>

票数 0
EN

Stack Overflow用户

发布于 2022-04-22 19:19:27

最佳实践是使用CSS Flexbox

代码语言:javascript
复制
        <div class="row no-gutters">
            <div class="col-xs-12 p-0" style="background-color:#f2f2f2;">                    
                <div class="col-xs-12 col-md-6 pt-1 px-5 text-description d-flex flex-wrap align-content-center justify-content-center" style="text-align:center;">
                    <h4 class="section-title text-left space-text" style="margin-bottom: 24px;text-transform: uppercase;">Pepe Calderin's Majestic Million Dollar Penthouse in Miami<div class="section-w-border"></div></h4>
                    <p style="text-transform: uppercase; color:#EC1B33;">Luxurious, Modern & Artistic</p>
                    <p>Famous for delivering unique design projects with high-end standards, Pepe Calderin partnered up with Essential Home, DelightFULL and Mid-Century Club to create the ultimate dream home that captures the heart of the popular city of Miami. This majestic luxury penthouse project presents us with design excellency, top-quality pieces, and an incredible view of one of the most luxurious marinas in the city.</p>
                    <p>Featuring a carefully chosen selection of costume furniture, bespoke lighting, and unique art pieces, this incredible modern penthouse design features 14 different experiences flowing throughout two floors on top of one of Miami's most luxurious skyscrapers. Don't miss out on the chance to discover this flamboyant design project that can also be seen as the ultimate dream home.</p>                        
                </div>
                <div class="col-xs-12 col-md-6 p-0">
                    <a class="swiper-anchor">
                        <img src="/images/campaigns/pepe-calderin/VIRTUALTOUR.jpg" alt="Karim Rashid House Chicago" class="img-responsive">                            
                    </a>                        
                </div>
            </div>
        </div>

根据类名,我假设您正在使用引导程序,如果不是,您将需要这些CSS类来使其工作。

代码语言:javascript
复制
  <style>
    .d-flex{
        display: flex;
    }
    .flex-wrap{
        flex-wrap: wrap;
    }
    .align-content-center{
        align-content: center;
    }
    .justify-content-center{
        justify-content: center;
    }
</style>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/71972028

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档