Display element outside the nested div while visibility stays hidden

倖福魔咒の 提交于 2019-12-02 04:25:36

Issue is because of collapsing margin.

Add border: 1px solid transparent; to slider class and give margin-top in negative to h1 tag like -40px, as in the code solution below.

body {
  background: yellow;
  padding: 50px;
}
.slider {
    width: 100%;
    height: 650px;
    margin-top: 40px;
    background: orange;
    box-shadow: 0 0 78px 11px #F3286B;
    border: 1px solid transparent;
}
h1, h2 {
  text-transform:uppercase;
  color: red;
}
h1 {
  font-size: 11vw;
  margin-top: -40px;
}
h2 {
  font-size: 7vw;
}
<body>
<div class="slider">
<h1>
Happy Fruit
</h1>
<h2>
HELLO WORLD
</h2>
</div>
</body>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!