編集:フロートベースのレイアウトに切り替えることでこの問題を解決できました。インラインブロックベースのグリッドを使用して問題の解決策があるかどうかは不明です。 (私はポジションを使うことができると思う:相対的または絶対的だが、それは悪い考えである)ここに私のCodepenがある:https://codepen.io/mattgwater/pen/yXBqoe(これは全画面で動作する)Ehsanの答えは基本的にこのレイアウトを行う方法を示している。良いコードの良い例。右の列のテキストが左の列の画像の下に表示されます
私はここの写真のテンプレートに基づいてウェブサイトを構築しようとしています。 https://assets.themuse.com/uploaded/attachments/14846.png?v=None
ただし、左の列に画像があると、右の列のすべてのテキストが画像の下に移動します。この問題を解決するにはどうすればよいですか?ここで
は私Codepenです:https://codepen.io/mattgwater/pen/yXBqoe?editors=1100#0
マイHTML
<!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>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/7.0.0/normalize.min.css">
<link rel="stylesheet" href="/Fonts/myFontsWebfontsKit/MyFontsWebfontsKit.css">
<link rel="stylesheet" href="/main.css">
</head>
<body>
<nav>
<div class="col left">
<div>
<h1 class="title">MATT GOLDWATER</h1>
</div>
</div><!--
--><div class="col right">
</div>
</nav>
<div class="nav-content-separator"></div>
<section>
<div class="col left">
<img class="profilepic" src="https://res.cloudinary.com/dyr8j9g6m/image/upload/v1496375439/my-headshot_bxpjqk.png" alt="Matt Goldwater">
<!--<p>yo</p>-->
</div><!--
--><div class="col right">
<p class="about">I want this sentence to be aligned with the top of the image.</p>
</div>
</section>
</body>
</html>
私のCSS(私もCSSを正規化する必要があり)あなたのコード内
html {
box-sizing: border-box;
}
*, *:before, *:after {
box-sizing: inherit;
}
.title {
color: #6fc3c3;
/*font-family: FuturaDCD-Lig;*/
font-weight: bold;
font-size: 32px;
text-align: center;
letter-spacing: .05em;
}
.col {
width: 50%;
display: inline-block;
/*white-space: nowrap;*/
}
.left {
padding-left: 10%;
}
.profilepic {
padding-top: 7%;
height: 450px;
margin: 0 auto;
display: block;
}
.nav-content-separator {
border: 1px solid #e8e8e8;
}
.about {
font-family: Avenir;
}
はあなたのCSS投稿してくださいことはできますか? –
@RalphDavidAbernathyおっと!ただした。 – MattGoldwater
'float:right;'を '.col.right'に追加しようとするとどうなりますか? –