「CSS」marginプロパティを個別に要素の外側の余白を指定する

2021年7月28日

書式
margin-top margin-right
margin-bottom margin-left
使用例

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<style>
.ka {
border: 2px solid SkyBlue;
width: 280px;
height: 120px;
}
.kb {
/*上側の幅*/
margin-top: 35px;
/*右側の幅*/
margin-right: 15px;
/*下側の幅*/
margin-bottom: 10px;
/*左側の幅*/
margin-left: 20px;
}
</style>
<div class="ka">
<div class="kb">margin要素の外側の余白を指定</div>
</div>
<style> .ka { border: 2px solid SkyBlue; width: 280px; height: 120px; } .kb { /*上側の幅*/ margin-top: 35px; /*右側の幅*/ margin-right: 15px; /*下側の幅*/ margin-bottom: 10px; /*左側の幅*/ margin-left: 20px; } </style> <div class="ka"> <div class="kb">margin要素の外側の余白を指定</div> </div>
<style>
  .ka {
    border: 2px solid SkyBlue;
    width: 280px;
    height: 120px;
  }
  .kb {
    /*上側の幅*/
    margin-top: 35px;
    /*右側の幅*/
    margin-right: 15px;
    /*下側の幅*/
    margin-bottom: 10px;
    /*左側の幅*/
    margin-left: 20px;
  }
</style>
<div class="ka">
  <div class="kb">margin要素の外側の余白を指定</div>
</div>

 

CSS

Posted by arkgame