移动问题,修改Bootstrap类或错误的媒体查询

时间:2019-02-15 17:47:30

标签: css twitter-bootstrap css3 bootstrap-4 media-queries

您可以立即看到我的媒体查询变得一团糟。我正在用项目符号创建此时间轴,并发现自己写了太多媒体查询,试图使项目符号与时间轴对齐

enter image description here

我非常相信自己在某个地方犯了错误。在非媒体查询的css部分中,也许在绝对位置区域中。我只是无法确定对齐方式。我的要求不是任何特定的屏幕尺寸,因此,我必须使其在所有屏幕上都达到最佳状态,我正在通过缩小浏览器宽度来进行测试。是否有引导解决方案?我写媒体查询的方式有误吗?

html {
  font-size: 18px;
}
@media (min-width: 576px) {
  .container {
    max-width: 540px;
 }
}
@media (min-width: 768px) {
  .container {
    max-width: 720px;
 }
}
@media (min-width: 992px) {
  .container {
    max-width: 960px;
 }
}
@media (min-width: 1200px) {
  .container {
    max-width: 1400px;
 }
}
h1, .h1 {
  font-size: 3.815rem;
}
h2, .h2 {
  font-size: 2.441rem;
}
h3, .h3 {
  font-size: 1.563rem;
}
h4, .h4 {
  font-size: 1.25rem;
}
.project-methodology-wrap {
  padding: 5rem 0;
 /*========== Media queries ==========*/
}
.project-methodology-wrap .methodologyBullet::before {
  content: '';
  width: 25px;
  height: 25px;
  background: #d4272e;
  position: absolute;
  border-radius: 30px;
  left: 26px;
  top: 0px;
  opacity: 0;
}
.project-methodology-wrap .methodologyBullet::after {
  content: '';
  width: 12px;
  height: 12px;
  background: #d4272e;
  position: absolute;
  border-radius: 30px;
  left: 33px;
  top: 2px;
}
.project-methodology-wrap .project-methodology-list.active .methodologyBullet {
  box-sizing: border-box;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
.project-methodology-wrap .project-methodology-list.active .methodologyBullet::before {
  opacity: 1;
  transition-duration: 0.5s;
  left: 26px;
}
.project-methodology-wrap .project-methodology-list.active .methodologyBullet::after {
  border: 5px solid #fff;
  width: 21px;
  height: 21px;
  left: 28px;
}
.project-methodology-wrap .project-methodology-listCount, .project-methodology-wrap .methodologyBullet {
  position: absolute;
  left: 0;
}
.project-methodology-wrap .project-methodology-leftContent {
  position: -webkit-sticky;
  position: sticky;
  top: 0;
}
.project-methodology-wrap .project-methodology-rightContent {
  position: relative;
  overflow: hidden;
}
.project-methodology-wrap .project-methodology-rightContent:before {
  content: "";
  height: 100%;
  width: 8px;
  position: absolute;
  background-color: #f1f2f6;
  left: 5.2%;
}
.project-methodology-wrap .project-methodology-rightContent .project-methodology-list {
  position: relative;
  -webkit-perspective: 1000px;
  perspective: 1000px;
  padding-left: 80px;
  margin-bottom: 3rem;
}
.project-methodology-wrap .project-methodology-rightContent .project-methodology-list .project-methodology-listContent {
  opacity: 0.2;
  transition-duration: 0.4s;
  -webkit-transform: none;
  transform: none;
}
.project-methodology-wrap .project-methodology-rightContent .project-methodology-list.active .project-methodology-listContent {
  opacity: 1;
}
@media only screen and (min-width: 1201px) and (max-width: 1280px) {
  .project-methodology-wrap .methodologyBullet {
    left: 0;
 }
}
@media only screen and (min-width: 1024px) and (max-width: 1200px) {
  .project-methodology-wrap .methodologyBullet {
    left: -1.4%;
 }
}
@media only screen and (min-width: 800px) and (max-width: 899px) {
  .project-methodology-wrap .methodologyBullet {
    left: 1.4%;
 }
}
@media only screen and (min-width: 768px) and (max-width: 799px) {
  .project-methodology-wrap .methodologyBullet {
    left: -4.2%;
 }
}
@media only screen and (max-width: 736px) {
  .project-methodology-wrap .methodologyBullet {
    left: -0.2%;
 }
}
@media only screen and (max-width: 640px) {
  .project-methodology-wrap .methodologyBullet {
    left: -0.2%;
 }
}
@media only screen and (max-width: 600px) {
  .project-methodology-wrap .methodologyBullet {
    left: -0.4%;
 }
}
@media only screen and (max-width: 570px) {
  .project-methodology-wrap .methodologyBullet {
    left: 0%;
 }
}
@media only screen and (max-width: 533px) {
  .project-methodology-wrap .methodologyBullet {
    left: -0.5%;
 }
}
@media only screen and (max-width: 480px) {
  .project-methodology-wrap .methodologyBullet {
    left: -1.3%;
 }
}
@media only screen and (max-width: 414px) {
  .project-methodology-wrap .methodologyBullet {
    left: -2.5%;
 }
}
@media only screen and (max-width: 384px) {
  .project-methodology-wrap .methodologyBullet {
    left: -3.4%;
 }
}
@media only screen and (max-width: 370px) {
  .project-methodology-wrap .methodologyBullet {
    left: -4.1%;
 }
}
@media only screen and (max-width: 320px) {
  .project-methodology-wrap .methodologyBullet {
    left: -5.4%;
 }
}
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>

    <script src="https://code.jquery.com/jquery-3.3.1.js" integrity="sha256-2Kok7MbOyxpgUVvAk/HJ2jigOSYS2auK4Pfzbm7uH60="
        crossorigin="anonymous"></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy"
        crossorigin="anonymous"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49"
        crossorigin="anonymous"></script>
    <script src="./index.js"></script>

    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO"
        crossorigin="anonymous">
    <link href="http://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css" rel="stylesheet">

    <link rel="stylesheet" type="text/css" href="./style/index.css">


</head>

<body>
    
    <section class="project-methodology-wrap">
        <div class="container">
            <div class="row">
                <div class="col-lg-6 col-md-6">
                    <div class="project-methodology-leftContent">
                        <div class="pr-5">
                            <h2>title</h2>
                            <p>
                                Lorem ipsum dolor sit amet consectetur adipisicing elit. Quasi, eum deserunt perferendis asperiores esse temporibus est numquam repellat doloremque suscipit enim quod nisi nam cum ea quam expedita quidem velit.
                            </p>
                        </div>
                        <img class="img-fluid pt-5 pb-5 pr-5" src="https://www.dropbox.com/s/5x8p2z5cvip5u38/chicago.jpg?dl=1">

                    </div>
                </div>
                <div class="col-lg-6 col-md-6">
                    <div class="project-methodology-rightContent pt-5">
                            <div class="project-methodology-list">
                                <div class="methodologyBullet">&nbsp;</div>
                                <div class="project-methodology-listContent">
                                    <h4 class="project-methodology-listCount">1</h4>
                                    <h4>
                                       Title
                                    </h4>
                                    <p>
                                       Lorem ipsum dolor sit, amet consectetur adipisicing elit. Ipsam, enim nam! Quisquam aliquid, harum reiciendis deleniti minima natus veniam. Fuga sunt rerum adipisci at et ad repellendus sint velit ducimus.

                                    </p>
                                </div>
                            </div>
                            <div class="project-methodology-list">
                                <div class="methodologyBullet">&nbsp;</div>
                                <div class="project-methodology-listContent">
                                    <h4 class="project-methodology-listCount">2</h4>
                                    <h4>
                                       Title
                                    </h4>
                                    <p>
                                       Lorem ipsum dolor sit, amet consectetur adipisicing elit. Ipsam, enim nam! Quisquam aliquid, harum reiciendis deleniti minima natus veniam. Fuga sunt rerum adipisci at et ad repellendus sint velit ducimus.

                                    </p>
                                </div>
                            </div>
                            <div class="project-methodology-list">
                                <div class="methodologyBullet">&nbsp;</div>
                                <div class="project-methodology-listContent">
                                    <h4 class="project-methodology-listCount">3</h4>
                                    <h4>
                                       Title
                                    </h4>
                                    <p>
                                       Lorem ipsum dolor sit, amet consectetur adipisicing elit. Ipsam, enim nam! Quisquam aliquid, harum reiciendis deleniti minima natus veniam. Fuga sunt rerum adipisci at et ad repellendus sint velit ducimus.

                                    </p>
                                </div>
                            </div>
                    </div>
                </div>
            </div>
        </div>
    </section>
 
 

</body>

</html>

我是CSS和移动领域的初学者,这是到目前为止的代码

3 个答案:

答案 0 :(得分:1)

看看这种方法:https://www.bootply.com/KBKYt3w6Z7

基本上,如果您可以调整标记以使:before和:after位于同一元素上,那么就不需要在时间表中使用所有这些媒体查询,然后可以将行和红点都定位到相同的位置/级别。

在该示例中,我将您的标记改为使用ul > li并进行了更改,以便时间轴CSS位于列表项中。

HTH

答案 1 :(得分:1)

以最小的努力,

https://stackblitz.com/edit/js-lvgwcp?file=style.css

我删除了所有CSS,并只获得了我想要的时间轴。因此,为您的项目添加所需的任何内容。这对于最小360px宽度的设备是敏感的。

我还做了一些html更改,这是我在这个div中添加的<div class="project-content">

无媒体查询。

请提供任何澄清评论。

我也没有任何用户界面,所以我从时间轴中分离了项目符号。如果需要,它可以与CSS的left属性对齐。

答案 2 :(得分:0)

答案是如此简单,我删除了所有媒体查询,并使用px代替了%

  

.project-methodology-wrap .project-methodology-rightContent:before

html {
  font-size: 18px;
}
@media (min-width: 576px) {
  .container {
    max-width: 540px;
 }
}
@media (min-width: 768px) {
  .container {
    max-width: 720px;
 }
}
@media (min-width: 992px) {
  .container {
    max-width: 960px;
 }
}
@media (min-width: 1200px) {
  .container {
    max-width: 1400px;
 }
}
h1, .h1 {
  font-size: 3.815rem;
}
h2, .h2 {
  font-size: 2.441rem;
}
h3, .h3 {
  font-size: 1.563rem;
}
h4, .h4 {
  font-size: 1.25rem;
}
.project-methodology-wrap {
  padding: 5rem 0;
 /*========== Media queries ==========*/
}
.project-methodology-wrap .methodologyBullet::before {
  content: '';
  width: 25px;
  height: 25px;
  background: #d4272e;
  position: absolute;
  border-radius: 30px;
  left: 26px;
  top: 0px;
  opacity: 0;
}
.project-methodology-wrap .methodologyBullet::after {
  content: '';
  width: 12px;
  height: 12px;
  background: #d4272e;
  position: absolute;
  border-radius: 30px;
  left: 33px;
  top: 2px;
}
.project-methodology-wrap .project-methodology-list.active .methodologyBullet {
  box-sizing: border-box;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
.project-methodology-wrap .project-methodology-list.active .methodologyBullet::before {
  opacity: 1;
  transition-duration: 0.5s;
  left: 26px;
}
.project-methodology-wrap .project-methodology-list.active .methodologyBullet::after {
  border: 5px solid #fff;
  width: 21px;
  height: 21px;
  left: 28px;
}
.project-methodology-wrap .project-methodology-listCount, .project-methodology-wrap .methodologyBullet {
  position: absolute;
  left: 0;
}
.project-methodology-wrap .project-methodology-leftContent {
  position: -webkit-sticky;
  position: sticky;
  top: 0;
}
.project-methodology-wrap .project-methodology-rightContent {
  position: relative;
  overflow: hidden;
}
.project-methodology-wrap .project-methodology-rightContent:before {
  content: "";
  height: 100%;
  width: 8px;
  position: absolute;
  background-color: #f1f2f6;
  left: 35px
}
.project-methodology-wrap .project-methodology-rightContent .project-methodology-list {
  position: relative;
  -webkit-perspective: 1000px;
  perspective: 1000px;
  padding-left: 80px;
  margin-bottom: 3rem;
}
.project-methodology-wrap .project-methodology-rightContent .project-methodology-list .project-methodology-listContent {
  opacity: 0.2;
  transition-duration: 0.4s;
  -webkit-transform: none;
  transform: none;
}
.project-methodology-wrap .project-methodology-rightContent .project-methodology-list.active .project-methodology-listContent {
  opacity: 1;
}

}
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>

    <script src="https://code.jquery.com/jquery-3.3.1.js" integrity="sha256-2Kok7MbOyxpgUVvAk/HJ2jigOSYS2auK4Pfzbm7uH60="
        crossorigin="anonymous"></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy"
        crossorigin="anonymous"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49"
        crossorigin="anonymous"></script>
    <script src="./index.js"></script>

    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO"
        crossorigin="anonymous">
    <link href="http://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css" rel="stylesheet">

    <link rel="stylesheet" type="text/css" href="./style/index.css">


</head>

<body>
    
    <section class="project-methodology-wrap">
        <div class="container">
            <div class="row">
                <div class="col-lg-6 col-md-6">
                    <div class="project-methodology-leftContent">
                        <div class="pr-5">
                            <h2>title</h2>
                            <p>
                                Lorem ipsum dolor sit amet consectetur adipisicing elit. Quasi, eum deserunt perferendis asperiores esse temporibus est numquam repellat doloremque suscipit enim quod nisi nam cum ea quam expedita quidem velit.
                            </p>
                        </div>
                        <img class="img-fluid pt-5 pb-5 pr-5" src="https://www.dropbox.com/s/5x8p2z5cvip5u38/chicago.jpg?dl=1">

                    </div>
                </div>
                <div class="col-lg-6 col-md-6">
                    <div class="project-methodology-rightContent pt-5">
                            <div class="project-methodology-list">
                                <div class="methodologyBullet">&nbsp;</div>
                                <div class="project-methodology-listContent">
                                    <h4 class="project-methodology-listCount">1</h4>
                                    <h4>
                                       Title
                                    </h4>
                                    <p>
                                       Lorem ipsum dolor sit, amet consectetur adipisicing elit. Ipsam, enim nam! Quisquam aliquid, harum reiciendis deleniti minima natus veniam. Fuga sunt rerum adipisci at et ad repellendus sint velit ducimus.

                                    </p>
                                </div>
                            </div>
                            <div class="project-methodology-list">
                                <div class="methodologyBullet">&nbsp;</div>
                                <div class="project-methodology-listContent">
                                    <h4 class="project-methodology-listCount">2</h4>
                                    <h4>
                                       Title
                                    </h4>
                                    <p>
                                       Lorem ipsum dolor sit, amet consectetur adipisicing elit. Ipsam, enim nam! Quisquam aliquid, harum reiciendis deleniti minima natus veniam. Fuga sunt rerum adipisci at et ad repellendus sint velit ducimus.

                                    </p>
                                </div>
                            </div>
                            <div class="project-methodology-list">
                                <div class="methodologyBullet">&nbsp;</div>
                                <div class="project-methodology-listContent">
                                    <h4 class="project-methodology-listCount">3</h4>
                                    <h4>
                                       Title
                                    </h4>
                                    <p>
                                       Lorem ipsum dolor sit, amet consectetur adipisicing elit. Ipsam, enim nam! Quisquam aliquid, harum reiciendis deleniti minima natus veniam. Fuga sunt rerum adipisci at et ad repellendus sint velit ducimus.

                                    </p>
                                </div>
                            </div>
                    </div>
                </div>
            </div>
        </div>
    </section>
 
 

</body>

</html>