2016-10-03 6 views
-2

内部要素を親にフィット/サイズ変更する方法が見つからないようです。ページ要素は次のように見終わると、私はサイズを変更として、幅が固定されている内部要素を親内に収める方法

enter image description here

:よう、現在のコードが見えます。

enter image description here

答えて

0

あなたはそのために(それを忘れないでください)position: relativeためposition: absoluteを使用することができます。

There isつ以上の解決策私は、たとえばについて

の上にこの技術を使用していますが:

.parent { 
 
    position: relative; 
 
    background-color: #d3d3d3; 
 
    border: 1px solid black; 
 
    width: 300px; 
 
    height: 100px; 
 
} 
 

 
.child { 
 
    position: absolute; 
 
    top: 5%; 
 
    left: 5%; 
 
    background-color: red; 
 
    border: 5px solid green; 
 
    box-sizing: border-box; 
 
    width: 90%; 
 
    height: 90%; 
 
}
<div class="parent"> 
 
    <div class="child"> 
 
    </div> 
 
</div>

関連する問題