如何将中间/中间框与滑块中的文本对齐,并在移动视图中进行响应? [英] How to align middle/center box with text in slider with responsive in mobile view ??

查看:134
本文介绍了如何将中间/中间框与滑块中的文本对齐,并在移动视图中进行响应?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是引导程序和网页设计的新手。我想创建一个具有移动响应的滑块,我想在滑块中间对齐框中的文本,并且它也会在响应中发生。所以帮我解决我如何做出响应?

I am new in bootstrap and web design .i want to create a slider with mobile responsive in which i want to align the text in box at middle of slider and also it happen in responsive as well. so help me to solve. How can i make responsive ??

    i made align center in desktop view but  in mobile view or responsive it won't happen.

Please Note: i am using bx slider here. (screenshot attached)
 Here is my code:

    <header>
        <div class="slider">
            <ul class="bxslider">
                <li><img src="images/slider.jpg" class="slide-img img-responsive"/>
                    <div  class="cap-box">
                        <p class="cap1">AIRFRESHENER</p>
                        <p class="cap2">OUR PRODUCT IS GOOD</p>
                    </div>

                </li>

                <li><img src="images/slider.jpg" class="slide-img img-responsive"/>
                    <div class="cap-box">
                        <p class="cap1">AIRFRESHENER</p>
                        <p class="cap2">OUR PRODUCT IS GOOD</p>
                    </div>
                </li>

                <li><img src="images/slider.jpg" class="slide-img img-responsive"/>
                    <div class="cap-box">
                        <p class="cap1">AIRFRESHENER</p>
                        <p class="cap2">OUR PRODUCT IS GOOD</p>
                    </div>
                </li>

            </ul>
        </div>

CSS file:

.slide-img
{
    width: 100%;
    /*height: 700px;*/
}
.bx-wrapper .bx-viewport
{
    -moz-box-shadow: none;
    -webkit-box-shadow: none;
    box-shadow: none;
}
.bx-viewport {
    position: static!important; /* center to page correctly */
    border: 0!important; /* border */
    -webkit-box-shadow: none!important; /* these two shadows */
    box-shadow: none!important;
}
.cap-box {
    position: absolute;
    margin-left:25%;
    background: rgba(0,0,0,0.5);
    top: 35%;
    width:660px;
    height: 180px;
    display: block;
    padding: 50px 0px;
}
.cap1
{
    font-family: Roboto, Serif;
    font-weight: 700;
    font-size: 36px;
    color: #ea6153;
    text-indent: 65px;
}
.cap2
{
    font-family: Roboto, serif;
    font-weight: 700;
    font-size: 48px;
    text-align: center;
    color: #ffffff;
    line-height: 13px;
}

[![This Screenshot is my desktop view][1]][1]
[![This is my Mobile view which is not responsive with slider(Airfreshener our product is good)][2]][2]


  [1]: https://i.stack.imgur.com/HpK0Y.jpg
  [2]: https://i.stack.imgur.com/HR4CH.png


推荐答案

检查这些并使用值来满足您的需求。只有css有变化。

Check these and play with the values to suit your needs. Changes are there in css only.



    .slide-img {
      width: 100%;
    }

    .bxslider li {
      position: relative;
    }

    .cap-box {
      position: absolute;
      left: 50%;
      top: 50%;
      transform: translate(-50%, -50%);
      padding: 50px;
      width: 80%;
      height: 30%;
      background: rgba(0, 0, 0, 0.5);
    }

    .cap1 {
      font-family: Roboto, Serif;
      font-weight: 700;
      font-size: 3.5vw;
      line-height: 0.5;
      color: #ea6153;
      text-indent: 20px;
    }

    .cap2 {
      font-family: Roboto, serif;
      font-weight: 700;
      font-size: 4.5vw;
      line-height: 1;
      color: #ffffff;
    }

这篇关于如何将中间/中间框与滑块中的文本对齐,并在移动视图中进行响应?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆