Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/78.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/40.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 引导4中的Flexbox表现怪异_Html_Css_Twitter Bootstrap_Flexbox - Fatal编程技术网

Html 引导4中的Flexbox表现怪异

Html 引导4中的Flexbox表现怪异,html,css,twitter-bootstrap,flexbox,Html,Css,Twitter Bootstrap,Flexbox,我正在尝试使用flexbox垂直对齐一个部分 这就是我试图垂直对齐的内容: HTML: 我不明白为什么flexbox不工作。我尝试了两个类,在任何可能的div中对齐内容/项目中心,但仍然无法使其工作 因为我有一个带背景图像的全宽div,它里面有一个容器div,我试图让它保持垂直。我真的不想在这上面加上200像素的保证金。这是一个Bootstrap 4错误吗?我将对齐项目中心类添加到flex div父类中,它成功了。只要你在.hm英雄上有一个高度,内容就会居中。希望这有帮助 .hm英雄{ 背景

我正在尝试使用flexbox垂直对齐一个部分

这就是我试图垂直对齐的内容:

HTML:

我不明白为什么flexbox不工作。我尝试了两个类,在任何可能的div中对齐内容/项目中心,但仍然无法使其工作


因为我有一个带背景图像的全宽div,它里面有一个容器div,我试图让它保持垂直。我真的不想在这上面加上200像素的保证金。这是一个Bootstrap 4错误吗?

我将
对齐项目中心
类添加到flex div父类中,它成功了。只要你在.hm英雄上有一个高度,内容就会居中。希望这有帮助

.hm英雄{
背景:url(“https://placehold.it/960x600)无重复;
背景尺寸:填充;
最小高度:600px;
}

今天就解决你的问题!

开始搜索您所在地区的承包商或公司,并在数小时内解决您的问题

提交
要对齐哪些元素?如何(顶部、中心、底部…)?整个“解决您今天的问题,将输入表单放在一起,与我设置的600px容器垂直对齐。现在我还看到东西也没有水平对齐。。。
<!--Top Hero Section -->
    <div class="d-flex hm-hero justify-content-center">
        <div class="container">
            <div class="row align-items-end">
                <div class="col-12">
                    <h1 class="text-center">Fix Your Problem Today!</h1>
                    <p class="text-center">Start searching for a contractor or company around your area and get your problem fixed in a matter of hours!</p>
                </div>

                <!--Form Section -->
                <div class="col-12">
                    <div class="form-group row justify-content-center">
                        <div class="col-12 col-md-6">
                            <input class="form-control" type="text" value="e.g. plumbing, carpentry" id="example-text-input">
                        </div>
                        <div class="col-12 col-md-4">
                            <input class="form-control" type="text" value="e.g. city name, postcode" id="example-text-input">
                        </div>
                        <div class="col-12 col-md-2">
                            <button type="submit" class="btn btn-primary">Submit</button>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
.hm-hero {
    background: url("../img/main_pic.png") no-repeat;
    background-size: fill;
    min-height: 600px;
}