CSSを使用して画像にボタンを追加するにはどうすればよいですか?
以下は、CSSを使用して画像にボタンを追加するためのコードです-
例
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
img{
width: 100%;
}
div {
position: relative;
width: 100%;
max-width: 400px;
}
div img {
width: 100%;
height: auto;
}
div button {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background-color: rgb(64, 21, 133);
color: white;
font-size: 20px;
padding: 24px 36px;
width: 220px;
border: none;
cursor: pointer;
border-radius: 5px;
text-align: center;
font-weight: bolder;
font-family: monospace,sans-serif,serif;
}
div button:hover {
color:yellow;
}
</style>
</head>
<body>
<h1>Button on Image Example</h1>
<div>
<img src="https://i.picsum.photos/id/354/400/400.jpg">
<button class="btn">Button</button>
</div>
</body>
</html> 出力
上記のコードは次の出力を生成します-
ボタンにカーソルを合わせると、ボタンの色が次のように変わります-
-
CSSで検索ボタンを作成するにはどうすればよいですか?
以下は、CSSで検索ボタンを作成するためのコードです- 例 <!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.c
-
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, s