CSSで要素のアスペクト比を維持するにはどうすればよいですか?
CSSを使用して要素のアスペクト比を維持するためのコードは、次のとおりです-
例
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
body{
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}
.aspectContainer {
background-color: rgb(191, 66, 216);
position: relative;
width: 100%;
padding-top: 75%;
}
.aspectText {
position: absolute;
text-align: center;
top: 0;
left: 0;
bottom: 0;
right: 0;
Text-align: center;
font-size: 20px;
color: white;
}
</style>
</head>
<body>
<h1>Aspect ratio example</h1>
<div class="aspectContainer">
<div class="aspectText">4:3 Aspect ratio</div>
</div>
<h2>Resize the window to see 4:3 aspect ratio in action</h2>
</body>
</html> 出力
上記のコードは次の出力を生成します-
ウィンドウのサイズを変更すると、要素は4:3-
の比率で縮小します。
-
CSSを使用して編集可能な要素から境界線を削除するにはどうすればよいですか?
編集可能な要素から境界線を削除するには、コードは次のとおりです- 例 <!DOCTYPE html> <html> <head> <style> body{ font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; } p{ font-size: 40px; } &n
-
CSSを使用して円形パス内の要素を移動する方法は?
CSSアニメーションは、組み合わせ、回転、変換することで、さまざまな方法で要素を変換するのに役立ちます。 次の例は、円形パスで要素を移動する方法を示しています。 例 <!DOCTYPE html> <html> <head> <style> div { margin: 8%; width: 35px; height: 35px; border-radius: 5px; background: red;