CSSでSVGアイコンを下部に固定した横並びのメニューがあるページ作る
作成した横並びメニュー画面
(参考)インラインSVG集はこちら
HTMLとCSS
<html lang="ja">
<head>
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1, maximum-scale=1, user-scalable=no">
<meta charset="UTF-8">
<style>
body{
color:#333;
margin:0;
padding:0;
background:linear-gradient(90deg,#FFF 0%, #EEE 50%, #CCC 80%, #666 100%);
}
header,footer,main,nav,article,aside,section{
display: block;
}
@media screen and (max-width:480px) {
/* 480以下 */
footer{
font-size:12px;
}
footer>a{
width:4em;
max-width:4em;
}
}
@media screen and (min-width:480px) and ( max-width:667px) {
/* 667以下 */
footer{
font-size:12px;
}
footer>a{
width:6em;
max-width:6em;
}
}
@media screen and (min-width:667px) {
/* 667を超える */
footer{
font-size:16px;
}
footer>a{
width:6em;
max-width:6em;
}
}
header{
font-size:16px;
/* background:#444; */
margin:0;
padding-top:0.2em;
padding-bottom:0.2em;
padding-left:0.1em;
padding-right:0.1em;
position:relative;
display:flex;
width:100%;
box-sizing:border-box;
}
main{
padding-top:0.2em;
padding-bottom:5em;
padding-left:0.1em;
padding-right:0.1em;
min-height:calc(100vh - 15em);
width:100%;
box-sizing:border-box;
}
footer{
position:fixed;
display:flex;
flex-wrap:wrap;
justify-content:center;
bottom:0;
left:0;
background:#444;
color:#DDD;
width:100%;
text-align:center;
box-sizing:border-box;
padding:0;
}
footer>a{
display:block;
font-size:1em;
color:#FFF;
text-decoration:none;
user-select:none;
padding:0.1em;
}
footer>a>svg{
display:block;
margin-left:auto;
margin-right:auto;
}
footer>a>p{
margin:0;
padding:0;
margin-left:auto;
margin-right:auto;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
width:100%;
max-width:100%;
}
</style>
<script>
</script>
</head>
<body>
<header>
<h1>タイトル等を入れる</h1>
</header>
<main>
<article>
<h2>アーティクル1</h2>
<section>
<h3>セクション1</h3>
<p>
本文を入れます<br>
<br>
<br>
</p>
</section>
<section>
<h3>セクション2</h3>
<p>
本文を入れます<br>
<br>
<br>
</p>
</section>
</article>
<article>
<h2>アーティクル2</h2>
<section>
<h3>セクション3</h3>
<p>
本文を入れます<br>
<br>
<br>
</p>
</section>
<section>
<h3>セクション4</h3>
<p>
本文を入れます<br>
<br>
<br>
本文最後
</p>
</section>
</article>
</main>
<footer>
<a href="">
<svg style="width:3em;height:3em;" viewBox="0 0 64 64">
<path d="M16,48 L16,28 L10,28 L32,12 L53,28 L45,28 L45,48 L37,48 L37,36 L29,36 L29,48" style="fill:#EEE;stroke:none;" />
</svg>
<p>Home</p>
</a>
<a href="">
<svg style="width:3em;height:3em;" viewBox="0 0 64 64">
<path d="M43,10 L52,19 L44,26 L36,18 z" style="fill:#EEE;stroke:none;" />
<path d="M33,20 L42,29 L25,46 L14,48 L16,37 z" style="fill:#EEE;stroke:none;" />
</svg>
<p>Edit</p>
</a>
<a href="">
<svg style="width:3em;height:3em;" viewBox="0 0 64 64">
<path d="M14,18 L49,18 L32,32 M14,20 L32,36 L49,20 L49,45 L14,45" style="fill:#EEE;stroke:none;" />
</svg>
<p>Mail</p>
</a>
<a href="">
<svg style="width:3em;height:3em;" viewBox="0 0 64 64">
<circle style="fill:none;stroke:#EEE;stroke-width:6;" cx="28" cy="28" r="14" />
<line style="fill:none;stroke:#EEE;stroke-width:6;" x1="38" y1="38" x2="50" y2="50" />
</svg>
<p>Search</p>
</a>
<a href="">
<svg style="width:3em;height:3em;" viewBox="0 0 64 64">
<path d="M25,14 L17,13 L13,17 L14,25 L 8,29 L 8,35 L14,39 L13,47 L17,51 L25,50 L29,56 L35,56 L39,50 L47,51 L51,47 L50,39 L56,35 L56,29 L50,25 L51,17 L47,13 L39,14 L35, 8 L29, 8 M27.4,20.9 A12.0,12.0 0,0,1 36.6,43.1 A12.0,12.0 0,0,1 27.4,20.9 z"
style="fill:#EEE;stroke:none;" />
</svg>
<p>Settings</p>
</a>
</footer>
</body>
</html>