「CSS」inline-blockで横に並べるサンプル

環境
Google Chrome 103.0.5060.66(Official Build)

構文
display: inline-block;
inline-blockは、inlineのように横に並べて表示します。
widthとheightの指定が効きます。

使用例

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<!DOCTYPE html>
<html>
<head>
<style>
.cft {
display: inline-block;
height: 50px;
background-color: skyblue;
}
</style>
</head>
<body>
<div class="cft">1111</div>
<div class="cft">2222</div>
<div class="cft">3333</div>
</body>
</html>
<!DOCTYPE html> <html> <head> <style> .cft { display: inline-block; height: 50px; background-color: skyblue; } </style> </head> <body> <div class="cft">1111</div> <div class="cft">2222</div> <div class="cft">3333</div> </body> </html>
<!DOCTYPE html>
<html>
<head>
<style>
  .cft {
    display: inline-block;
    height: 50px;
    background-color: skyblue;
  }
</style>
</head>
<body>

<div class="cft">1111</div>
<div class="cft">2222</div>
<div class="cft">3333</div>
</body>
</html>

結果
div要素をinlineのように横に並べて表示します。

CSS

Posted by arkgame