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.
ネイティブにレンダリングされた高さに対して div の高さを減らすにはどうすればよいですか?
かなり単純な質問のように思えますが、高さをパーセンテージに設定することはオプションではありません。また、(明らかに) div 内にサイズを小さくできる要素がないか、margin: 0 -10px 0 0;またはpadding: 0 -10px 0 0;ありません。マージンを適用すると、それは動作するようです。このプロセスにより、border-radius が損なわれます。
margin: 0 -10px 0 0;
padding: 0 -10px 0 0;
jqueryを使用:
$('div').animate({'height':'-=10px'}, 1000);
「-=10px」は、現在の高さを 10px 減らします。