Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
width プロパティに calc を記述する理由 幅:100% - 80px; = width:calc(100% - 80px); ここにhtmlとここ <div>any text here</div> にcss
<div>any text here</div>
div{ background:#f00; width:calc(100% - 10px); padding:30px;
}
サンプル コードは、div の幅がコンテナーの 100% 未満の 10 ピクセルであることを示しています。他にどのようにしますか?
親コンテナの幅が 100% の場合 (実際の幅は (流体設計では) わかりません)、親よりも 10 ピクセル小さくしたいことがわかっています。
あなたの質問に答えるために、なぜですか?多くの*さまざまな理由があり、誰もが「なぜ」がより重要であるかについて意見を持っています. どのように使用されるかを調べて、いつ使用するかを決定することをお勧めします。