logo

フレックスボックス間のスペースを設定するにはどうすればよいですか?

Flexbox間のスペースを設定する アイテムには次のようなプロパティの使用が含まれます コンテンツの正当化 のような値を持つ 間のスペース または 周囲の空間 、 そして ギャップ 、主軸に沿ってアイテム間のスペースを均等に分散し、フレキシブル コンテナー内のレイアウトの間隔と配置を強化します。

次のようなアプローチがいくつかあります。

目次



1. justify-content プロパティを使用します。

justify-content プロパティ CSSフレックスボックス フレックス項目を主軸に沿って配置します。 flex-start、flex-end、center、space-between、space-around、space-evenly などの値を使用して項目間のスペースを分散し、フレックス コンテナー内の配置と間隔を制御できます。

構文:

  • 値 space-between は、行間にスペースのあるフレックス項目を表示するために使用されます。
justify-content: space-between;>
  • space-around 値は、行の間、行の前後にスペースを入れてフレックス項目を表示するために使用されます。
justify-content: space-around;>

例: この例では、CSS Flexbox で justify-content を使用して項目間のスペースを分配する例を示します。 space-around は項目の周囲に均等な空間を作成し、space-between は項目間に均等な空間を配置します。

html
   flexboxtitle> 間のスペース<style>.flex2 { 表示: フレックス;  コンテンツの位置揃え: 周囲のスペース;  背景色: 緑;  .flex3 { 表示: フレックス;  コンテンツの位置揃え: 間のスペース;  背景色: 緑;  .flex-items {背景色: #f4f4f4;  幅: 100ピクセル;  高さ: 50ピクセル;  マージン: 10px;  テキスト整列: 中央;  フォントサイズ: 40px;  h3 {テキスト整列:中央;  .geeks { フォントサイズ: 40px;  テキスト整列: 中央;  色: #009900;  フォントの太さ: 太字;  スタイル>頭> <body> <div>techcodeview.comdiv><h3>flexboxh3> 間のスペース <br>  <b>justify-content: 周囲のスペース b><div> <div>1div><div>2div><div>3div> div> <br>  <b>justify-content: スペース間の b><div> <div>1div><div>2div><div>3div> div> <br>本文> html>>></pre> </code> <p dir='ltr'>  <b>  <strong>出力:</strong>  </b>  </p> <p dir='ltr'> <img src='//techcodeview.com/img/css-misc/95/how-set-space-between-flexbox.webp' alt="フレックスボックス間のスペースの設定"></p> <h2 id='2-using-the-gap-property-to-set-space'>  <b>  <strong>2</strong>  </b>  <span>。の使用</span>  <b>  <strong>ギャップ特性</strong>  </b>  <span>スペースを設定するには</span></h2><p dir='ltr'><span>の</span> <span>CSSのgapプロパティ</span> <span>フレックスボックスまたはグリッド項目間のスペースを設定します。これは行ギャップと列ギャップの略称であり、余分なマージンやパディングを使用せずに一貫した間隔を管理することが容易になり、レイアウトの制御と読みやすさが向上します。</span></p> <p dir='ltr'>  <b>  <strong>構文:</strong>  </b>  </p> <pre class='hljs'>gap: value;></pre><p dir='ltr'>  <b>  <strong>例:</strong>  </b>  <span>この例では、gap プロパティと flexbox プロパティを使用して、個々の項目間にギャップを追加しています。</span></p>HTML<code class='hljs'> <pre class='hljs'> <html> <head> <style>.flex-container { 表示: フレックス;  ギャップ: 20px;  /* フレックス項目間に必要な間隔を設定します */ } .flex-item {background-color: lightblue;  パディング: 10px;  .geeks { フォントサイズ: 40px;  色: #009900;  フォントの太さ: 太字;  スタイル>頭> <body> <div>techcodeview.comdiv><h3>ギャッププロパティの使用h3><div> <div>要素 1div><div>要素 2div><div>要素 3div> div> body> html>>></pre> </code> <p dir='ltr'>  <b>  <strong>出力:</strong>  </b>  </p>  <img src='//techcodeview.com/img/css-misc/95/how-set-space-between-flexbox-2.webp' alt="">  <br>  <br></article><div class="rekl_placeholder"><script type="text/javascript">atOptions = {'key' : 'f2b09f3e7178b263531e10998e9a32fa','format' : 'iframe','height' : 250,'width' : 300,'params' : {}};</script><script type="text/javascript" src="//spiritscaution.com/f2b09f3e7178b263531e10998e9a32fa/invoke.js"></script></div> </article>
                         
                        </div><!--//content-->
                    </div><!--//section-inner-->                 
                </section><!--//section-->
    
            </div><!--//primary-->
            <div class="secondary col-md-4 col-sm-12 col-xs-12">
                  <aside class="info aside section">
                    <div class="section-inner">
                        <h2 class="">カテゴリ</h2>
                        <div class="content">
                            <ul class="list-unstyled">
                                <li> <a href="/data-visualization/">データの視覚化</a> </li><li> <a href="/svn-tutorial/">Svn チュートリアル</a> </li><li> <a href="/cyber-defence-intelligence/">サイバー防御インテリジェンス</a> </li><li> <a href="/python-loop-programs/">Python ループ プログラム</a> </li><li> <a href="/complexity-analysis/">複雑さの分析</a> </li><li> <a href="/python-string/">Python文字列</a> </li><li> <a href="/banking-english/">銀行英語</a> </li><li> <a href="/square-root/">平方根</a> </li><li> <a href="/android-tips-tricks/">Android のヒント トリック</a> </li><li> <a href="/alphabet/">アルファベット</a> </li>
                                
                            </ul>
                        </div><!--//content-->  
                    </div><!--//section-inner-->                 
                </aside><!--//aside-->
                
                 <aside class="testimonials aside section">
                	 <div class="section-inner">
                        <div class="content">
                            <div class="item">
  								<div class="rekl_placeholder" id="sidebar_placeholder_1"> <script type="text/javascript">atOptions = {'key' : 'f53f1abf3c3a788f849c12a956865db1','format' : 'iframe','height' : 300,'width' : 160,'params' : {}};</script><script type="text/javascript" src="//spiritscaution.com/f53f1abf3c3a788f849c12a956865db1/invoke.js"></script> <br></div>                                                   
                            </div>
                        </div>
                    </div>
                   <div class="section-inner">
                        <h2 class="heading">Python の *args と **kwargs</h2>
                        <div class="content">
                            <div class="item">
                                 <blockquote class="quote">                                  
                                    <span> <i class="fa fa-quote-left"></i> オタク向けのコンピューター サイエンス ポータル。これには、よく書かれ、よく考えられ、よく説明されたコンピューター サイエンスとプログラミングの記事、クイズ、練習/競技プログラミング/企業面接の質問が含まれています。</span>
                                </blockquote>                
                                                                                             
                            </div><!--//item-->
                            
                            <p> <a class="more-link" href="/args-kwargs-python"> <i class="fa fa-external-link"></i> 続きを読みます</a> </p> 
                            
                        </div><!--//content-->
                    </div><!--//section-inner-->
                </aside><!--//section-->
                
               
                            
                 <aside class="languages aside section">
                    <div class="section-inner">
                        <h2 class="heading">興味深い記事</h2>
                        <div class="content">
                            <ul class="list-unstyled">
                                <li class="item">
                                    <span class="title"> <strong> <a href="/how-concatenate-two-strings-c">C++で2つの文字列を連結するにはどうすればよいですか?</a> </strong> </span>
                                    
                                </li><!--//item--><li class="item">
                                    <span class="title"> <strong> <a href="/python-int-function">Python int() 関数</a> </strong> </span>
                                    
                                </li><!--//item--><li class="item">
                                    <span class="title"> <strong> <a href="/computer-network-architecture">コンピュータネットワークアーキテクチャ</a> </strong> </span>
                                    
                                </li><!--//item--><li class="item">
                                    <span class="title"> <strong> <a href="/what-states-are-3-hours-ahead-california">カリフォルニアより 3 時間進んでいるのはどの州ですか?</a> </strong> </span>
                                    
                                </li><!--//item--><li class="item">
                                    <span class="title"> <strong> <a href="/joe-biden-net-worth-2024">ジョー・バイデン純資産 2024 (米国大統領純資産)</a> </strong> </span>
                                    
                                </li><!--//item-->
                               
                            </ul>
                        </div><!--//content-->
                    </div><!--//section-inner-->
                </aside><!--//section-->
                
              
                 <aside class="list music aside section">
                    <div class="section-inner">
                        <h2 class="heading">人気の投稿</h2>
                        <div class="content">
                            <ul class="list"> <li><a href="/how-enable-disable-developer-options-android">Androidの開発者モードをオフにする</a>
</li><li><a href="/java-string-substring">メソッドの部分文字列 Java</a>
</li><li><a href="/how-remove-first-character-excel">Excelで最初の文字を削除する</a>
</li><li><a href="/abstract-class-java">Java抽象クラス</a>
</li><li><a href="/javascript-onclick-event">JavaScript オンクリック</a>
</li> 
                                
                                
                            </ul>
                        </div><!--//content-->
                    </div><!--//section-inner-->
                </aside><!--//section-->
              
            </div><!--//secondary-->    
        </div><!--//row-->
    </div><!--//masonry-->
    
	    <footer class="footer">
        <div class="container text-center">
                <span>
Copyright ©2025 全著作権所有 |  <a href="//sr.techcodeview.com/">techcodeview.com</a> | <a href="/disclaimer" rel="nofollow noopener noreferrer" target="_blank">免責事項</a>  |  <a href="/about-us" rel="nofollow noopener noreferrer" target="_blank">私たちについて</a>  |  <a href="/privacy-policy" rel="nofollow noopener noreferrer" target="_blank">プライバシーポリシー</a>  </span>
        </div>
    </footer>
 
         
    <script type="text/javascript" src="https://techcodeview.com/template/assets/plugins/jquery-1.11.3.min.js"></script>
    <script type="text/javascript" src="https://techcodeview.com/template/assets/plugins/bootstrap/js/bootstrap.min.js"></script>    
    

    <script type="text/javascript" src="https://techcodeview.com/template/assets/js/main.js"></script>     
	
	<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/11.5.1/highlight.min.js"></script>
	
</body>
</html>