div内の見出しをイメージと重複させたいので、幅50%のイメージとdivのテキスト65%があります。しかし、問題は、div内の他のコンテンツがイメージと重なり合うことを望まないということです。私は、テキストとボタンの上に画像の横にしたい。 しかし、私はそれを把握していないようです。ここで親divの左に子divを配置しますか?
はCodepenです:https://codepen.io/tayanderson/pen/EbJZxy
.project {
height: 75vh;
margin: 15em 0;
position: relative;
.project-info {
z-index: 100;
display: flex;
flex-direction: column;
justify-content: center;
position: absolute;
width: 65%;
height: 100%;
right: 0;
h2 {
text-transform: initial;
color: #eee;
}
p {
font-weight: 300;
color: #ccc;
margin: 40px 0;
}
.project-desc {
width: 70%;
.button {display:inline-block;}
}
}
.project-img {
background-size: cover;
background-position: center;
height: 100%;
-webkit-filter: grayscale(100%) brightness(50%);
filter: grayscale(100%) brightness(50%);
width: 51.3%;
}
a {text-decoration:none;
color: #fff;}
@media only screen and (max-width: 768px) {
.project-info, .project-img {
width: 100%;
}
.project-info {
left: 0;
padding: 0 20px;
.project-desc>*{
width: 100% !important;
float: left !important;
}
p {display: none;}
}
}
}
ありがとう!はい、それは私が説明しようとしていたものです。これはうまくいきましたが、唯一の問題はdivを垂直方向に中心に置くことでした。現在、私はflexboxを使っています。私がこれをするとき、それを無効にするようです。 – andersts
あなたがまだフレックスボックスを使用できるという心配はありません。私は、コンテンツが垂直方向にセンタリングされるようにcodepenを更新しました。 – Alex