Html Flexbox中的定心不工作。高度、宽度、显示和位置要求是什么?我错过了什么?

Html Flexbox中的定心不工作。高度、宽度、显示和位置要求是什么?我错过了什么?,html,css,flexbox,center,blogs,Html,Css,Flexbox,Center,Blogs,好的,我正在为WP中的博客归档页面设置样式,我遇到了flexbox问题 我已经检查了许多类似的问题,但我似乎无法确定我做错了什么 编辑:已将其标记为重复项。虽然这个网站上确实有很多帖子详细介绍了人们在使用flexbox进行中心处理时遇到的问题,但这些解决方案对我来说并不奏效,我认为是我的代码中的某些特定内容导致了问题的出现 这就是我在标题中明确询问flexbox是否有正常运行的高度、宽度、显示或位置要求的原因之一,因为我使用的是最小宽度和最小高度,而不是明确的宽度和高度,我从其他一些帖子中认为这

好的,我正在为WP中的博客归档页面设置样式,我遇到了flexbox问题

我已经检查了许多类似的问题,但我似乎无法确定我做错了什么

编辑:已将其标记为重复项。虽然这个网站上确实有很多帖子详细介绍了人们在使用flexbox进行中心处理时遇到的问题,但这些解决方案对我来说并不奏效,我认为是我的代码中的某些特定内容导致了问题的出现

这就是我在标题中明确询问flexbox是否有正常运行的高度、宽度、显示或位置要求的原因之一,因为我使用的是最小宽度和最小高度,而不是明确的宽度和高度,我从其他一些帖子中认为这可能是问题的一部分,但我找不到flexbox规范中详细说明该行为的部分

这是我的密码笔

下面是代码本身:

<section class=" blog-post-section container-fluid">
        <a href="http://www.josvanriswick.com/images/apple-pear-stilllife_400.jpg">


        <div class="img-container rellax" data-rellax-speed="-4">
            <img class="section-img rellax" data-rellax-speed="-6" src="http://www.cashartblog.com/wp-content/uploads/2012/09/peppers7.jpg">
            <polygon points="345.606,107.5 324.394,128.713 418.787,223.107 0,223.107 0,253.107 418.787,253.107 324.394,347.5   345.606,368.713 476.213,238.106 " fill="#FFFFFF">
        </polygon></div>
        <div class="title-card-flex">
            <h1 class="class-study-title"> <span class="">Test Post Nietzsche</span></h1>
            <p class="blog-summary"><span>War spirit strong sexuality will play right deceptions noble prejudice noble derive chaos. Burying disgust contradict passion overcome. Chaos play evil reason hope of overcome oneself pinnacle spirit enlightenment. Will ascetic ubermensch holiest superiority sea selfish pious law. Overcome selfish chaos snare convictions truth deceptions snare reason. Self noble salvation insofar god christian joy marvelous. […]</span></p>


        </div>

            </a>
    </section>

<section class=" blog-post-section container-fluid">
        <a href="http://www.josvanriswick.com/images/apple-pear-stilllife_400.jpg">


        <div class="img-container rellax" data-rellax-speed="-4">
            <img class="section-img rellax" data-rellax-speed="-6" src="http://www.cashartblog.com/wp-content/uploads/2012/09/peppers7.jpg">
            <polygon points="345.606,107.5 324.394,128.713 418.787,223.107 0,223.107 0,253.107 418.787,253.107 324.394,347.5   345.606,368.713 476.213,238.106 " fill="#FFFFFF">
        </polygon></div>
        <div class="title-card-flex">
            <h1 class="class-study-title"> <span class="">Test Post Nietzsche</span></h1>
            <p class="blog-summary"><span>War spirit strong sexuality will play right deceptions noble prejudice noble derive chaos. Burying disgust contradict passion overcome. Chaos play evil reason hope of overcome oneself pinnacle spirit enlightenment. Will ascetic ubermensch holiest superiority sea selfish pious law. Overcome selfish chaos snare convictions truth deceptions snare reason. Self noble salvation insofar god christian joy marvelous. […]</span></p>


        </div>

            </a>
    </section>

<section class=" blog-post-section container-fluid">
        <a href="http://www.josvanriswick.com/images/apple-pear-stilllife_400.jpg">


        <div class="img-container rellax" data-rellax-speed="-4">
            <img class="section-img rellax" data-rellax-speed="-6" src="http://www.cashartblog.com/wp-content/uploads/2012/09/peppers7.jpg">
            <polygon points="345.606,107.5 324.394,128.713 418.787,223.107 0,223.107 0,253.107 418.787,253.107 324.394,347.5   345.606,368.713 476.213,238.106 " fill="#FFFFFF">
        </polygon></div>
        <div class="title-card-flex">
            <h1 class="class-study-title"> <span class="">Test Post Nietzsche</span></h1>
            <p class="blog-summary"><span>War spirit strong sexuality will play right deceptions noble prejudice noble derive chaos. Burying disgust contradict passion overcome. Chaos play evil reason hope of overcome oneself pinnacle spirit enlightenment. Will ascetic ubermensch holiest superiority sea selfish pious law. Overcome selfish chaos snare convictions truth deceptions snare reason. Self noble salvation insofar god christian joy marvelous. […]</span></p>


        </div>

            </a>
    </section>


<section class=" blog-post-section container-fluid">
        <a href="http://www.josvanriswick.com/images/apple-pear-stilllife_400.jpg">


        <div class="img-container rellax" data-rellax-speed="-4">
            <img class="section-img rellax" data-rellax-speed="-6" src="http://www.cashartblog.com/wp-content/uploads/2012/09/peppers7.jpg">
            <polygon points="345.606,107.5 324.394,128.713 418.787,223.107 0,223.107 0,253.107 418.787,253.107 324.394,347.5   345.606,368.713 476.213,238.106 " fill="#FFFFFF">
        </polygon></div>
        <div class="title-card-flex">
            <h1 class="class-study-title"> <span class="">Test Post Nietzsche</span></h1>
            <p class="blog-summary"><span>War spirit strong sexuality will play right deceptions noble prejudice noble derive chaos. Burying disgust contradict passion overcome. Chaos play evil reason hope of overcome oneself pinnacle spirit enlightenment. Will ascetic ubermensch holiest superiority sea selfish pious law. Overcome selfish chaos snare convictions truth deceptions snare reason. Self noble salvation insofar god christian joy marvelous. […]</span></p>


        </div>

            </a>
    </section>


<section class=" blog-post-section container-fluid">
        <a href="http://www.josvanriswick.com/images/apple-pear-stilllife_400.jpg">


        <div class="img-container rellax" data-rellax-speed="-4">
            <img class="section-img rellax" data-rellax-speed="-6" src="http://www.cashartblog.com/wp-content/uploads/2012/09/peppers7.jpg">
            <polygon points="345.606,107.5 324.394,128.713 418.787,223.107 0,223.107 0,253.107 418.787,253.107 324.394,347.5   345.606,368.713 476.213,238.106 " fill="#FFFFFF">
        </polygon></div>
        <div class="title-card-flex">
            <h1 class="class-study-title"> <span class="">Test Post Nietzsche</span></h1>
            <p class="blog-summary"><span>War spirit strong sexuality will play right deceptions noble prejudice noble derive chaos. Burying disgust contradict passion overcome. Chaos play evil reason hope of overcome oneself pinnacle spirit enlightenment. Will ascetic ubermensch holiest superiority sea selfish pious law. Overcome selfish chaos snare convictions truth deceptions snare reason. Self noble salvation insofar god christian joy marvelous. […]</span></p>


        </div>

            </a>
    </section>


<section class=" blog-post-section container-fluid">
        <a href="http://www.josvanriswick.com/images/apple-pear-stilllife_400.jpg">


        <div class="img-container rellax" data-rellax-speed="-4">
            <img class="section-img rellax" data-rellax-speed="-6" src="http://www.cashartblog.com/wp-content/uploads/2012/09/peppers7.jpg">
            <polygon points="345.606,107.5 324.394,128.713 418.787,223.107 0,223.107 0,253.107 418.787,253.107 324.394,347.5   345.606,368.713 476.213,238.106 " fill="#FFFFFF">
        </polygon></div>
        <div class="title-card-flex">
            <h1 class="class-study-title"> <span class="">Test Post Nietzsche</span></h1>
            <p class="blog-summary"><span>War spirit strong sexuality will play right deceptions noble prejudice noble derive chaos. Burying disgust contradict passion overcome. Chaos play evil reason hope of overcome oneself pinnacle spirit enlightenment. Will ascetic ubermensch holiest superiority sea selfish pious law. Overcome selfish chaos snare convictions truth deceptions snare reason. Self noble salvation insofar god christian joy marvelous. […]</span></p>


        </div>

            </a>
也许你想要这样的东西


您的实际问题是什么?哪个元素应该居中?你试过什么?你到底想做什么?它应该水平居中还是垂直居中?@actc我正在尝试将图像置于图像容器内部的中心位置。问题是它是基于整个页面居中,而不是基于应该包含它的图像容器。@UncaughtTypeError当我使用justifycontent和align items center时,我认为我试图将两者居中,但我应该更明确。看来我应该在我原来的帖子里多加解释。很抱歉不够清晰。你是对的,这个网站上有很多关于如何使用flexbox水平和垂直居中的帖子,每个帖子平均有几个不同的答案。对于如何使用CSS属性将当前可用的内容置于中心位置的问题,我们无法提出一个在这里已经回答了十几次的问题。至于你的情况,你还没有提供一个MCVE,所以即使你提出了一个新的问题,也没有被正确地问到。是的,这就是我想要的效果,但我试图避免使用背景url css解决方案,因为这与WP post field系统不兼容。我想我最终可能会使用这个解决方案,因为我有点不知所措。修复--->它使用图像标签:)哦,亲爱的,谢谢你,约丹,这是一个比我尝试做的更优雅的解决方案。此外,它看起来对象适合现在有体面的浏览器支持!事实上,由于两个原因,对象匹配对我来说不起作用。主要的问题是,object-fit:fill将挤压图像,而object-fit:contain将不显示图像的完整大小,并允许溢出,这是一个更大的问题,因为我正在为这些图像添加视差。该死,这是一次很好的尝试!好吧,事实上也许掩护会奏效。但仍不确定它将如何与视差相互作用。
section.blog-post-section {
      width: 100%;
      position: relative;
      min-height: 450px;
      overflow: hidden;
      z-index: 2000;
      padding: 0px;
      box-shadow: 0 10px 20px rgba(0, 0, 0, 0.19), 0 6px 6px rgba(0, 0, 0, 0.23);


      a {
        height: 100%;
        width: 100%;
        text-decoration: none;
        z-index: 5000;
        cursor: pointer !important;
        display: flex;
        flex: 1;


        div.overlay {
          position: absolute;
          z-index: 3000;
          width: 100%;
          height: 100%;
          box-shadow: rgba(0, 0, 0, 0.8) 3px 3px 10px inset;
          background: linear-gradient(rgba(0, 0, 0, 0.0), rgba(0, 0, 0, 0.5));

        }
        //end overlay container

        div.img-container {
          position: absolute;
          display: flex;
          min-width: 50%;
          min-height: 100%;
         display: flex;
         justify-content: center;
          align-items: center;

          img.section-img {
            position: relative;
            min-width: 100%;
            min-height: calc(100% + 200px);
            z-index: 2000 !important;
            filter: blur(2px);
            top: -100px;
            right: 0;
            margin: 0 auto;

          }
          svg {
            float: right;
            background-color: black;
          }

        }


        //end image container

        div.title-card-flex {
          padding: 50px;
          position: absolute;
          height: 100%;
          width: calc(50% - 100px);
          flex-direction: column;
          justify-content: left;
          align-items: flex-start;
          z-index: 4000;
          background: white;

          h1 {
            position: relative;

            background-color: black;
            font-family: 'AllerBold', Arial, sans-serif;
            color: white;
            text-align: left;
            text-shadow: 0 2px 2px rgba(0, 0, 0, .35);
            max-width: 90vw;
            margin: 50px 10px 25px 50px;
            padding: 10px;
            z-index: 4000;
            user-select: none;
            cursor: pointer !important;
            font-size: 3.5vmax;
            font-size: 25px;

          }

          p.blog-summary {
            display: block;
            position: relative;
            padding: 5px;
            margin: 25px 10px 45px 50px;
            font-family: 'Aller', Arial, sans-serif;
            color: white;
            text-align: left;
            text-shadow: 0 2px 2px rgba(0, 0, 0, .35);
            z-index: 4000;
            user-select: none;
            cursor: pointer !important;
            line-height: 1.4;
            font-size: 18px;
            margin-bottom: 10px;

            span {
              background-color: black;
              box-shadow: 0.2em 0 0 rgba(black, 1), -0.2em 0 0 rgba(black, 1);
              display: inline;
            }

          }

          //svg {
          //  float: right;
          //  background-color: black;
          //}

        }
      }
    }

    section.blog-post-section:nth-child(even)  {
    div.img-container{
      right: 0px;


    }
    }

    section.blog-post-section:nth-child(odd) {
      div.title-card-flex {
        right: 0px;


      }
    }
/*
 * hor align
 */
align-items: center;
/*
 * vertical align
 */
justify-content: center