前提・実現したいこと
html css で複数の<div>要素を中央寄せしたいです。
まだまだ初心者で。。。教えて頂ければ幸いです
発生している問題・エラーメッセージ
色々試したのですが、 左寄せのままになってしまっています
該当のソースコード
<div class="header03"> <div class="header03menu"> <div class="header0301"> <img src="assets/images/logo02.png"> </div> <div class="header0302"> <div class="cp_ipselect cp_sl01"> <select required=""> <option value="" hidden="">全てのカテゴリー</option> <option value="1">ビューティ・コスメ</option> <option value="2">ビューティ・コスメ</option> <option value="3">ビューティ・コスメ</option> <option value="4">ビューティ・コスメ</option> </select> </div> </div> <div class="header0304"> <form action="" method="post"> <input type="search" name="q" value="" placeholder="キーワードや商品番号を探す"><input type="submit" name="btn_search" value="検索"> </form> </div> <div class="header0303"> <div class="iconmenu"> <a href=""><img src="assets/images/icon01.png"> <p>閲覧履歴</p></a> </div> <div class="iconmenu"> <a href=""><img src="assets/images/icon02.png"> <p>ログイン</p></a> </div> <div class="iconmenu"> <a href=""><img src="assets/images/icon03.png"> <p>お気に入り</p></a> </div> <div class="iconmenu"> <a href=""><img src="assets/images/icon04.png"> <p>カート</p></a> </div> </div> </div> </div> .header03{ margin-top: 20px; } .header03menu{display:flex; } .header0302{padding-left: 30px; } .cp_ipselect {overflow: hidden; width: 100%;margin: 2em auto; text-align: center;} .cp_ipselect select { width: 100%; padding-right: 1em; cursor: pointer; text-indent: 0.01px; text-overflow: ellipsis; border: none;outline: none;background: transparent; background-image: none; box-shadow: none; -webkit-appearance: none; appearance: none;} .cp_ipselect select::-ms-expand { display: none;} .cp_ipselect.cp_sl01 { position: relative; border: 1px solid #bbbbbb; background: #ffffff; margin: 0;} .cp_ipselect.cp_sl01::before {position: absolute;top: 1em;right: 0.9em;width: 0;height: 0;padding: 0; content: '';border-left: 6px solid transparent; border-right: 6px solid transparent;border-top: 6px solid #666666;pointer-events: none;} .cp_ipselect.cp_sl01 select { padding: 8px 38px 8px 8px; color: #666666;} input[type=search] { -webkit-appearance: none; display: inline-block; margin-right: 0; padding: 10px;width: 300px;height: 39px;font-size: 100%; box-sizing: border-box; border: 1px solid #ccc; border-right: none;} input[type=submit] { -webkit-appearance: none; display: inline-block; padding: 0 10px; color: #fff; width: 50px; height: 39px; font-size: 100%; vertical-align: top; border: none; background: #d65353;} .header04{ background: #a4dfc1; display: flex; justify-content: center; align-items: center;height: 50px;} .gnav { display: flex; height: 2rem; margin: 0 auto; width: 1000px; padding: 0;} .gnav > li {width: 25%;} .gnav li { list-style: none; position: relative;} .gnav li a { background: #a4dfc1; color: #000; display: block; height: 2rem; line-height: 2rem; text-align: center; text-decoration: none; width: 100%;} /*子階層以降共通*/ .gnav li li { height: 0; overflow: hidden; transition: .5s; z-index: 1000;} .gnav li li a { border-top: 1px solid #eee; text-align: left; padding-left: 5px;} .gnav li:hover > ul > li { height: 2rem; overflow: visible;} .gnav .gnavtitle::after { position: absolute;top: 13px; right: 16px; display: block; width: 5px; height: 5px; content: ""; transform: rotate(45deg); -ms-transform: rotate(45deg); border-right: 1px solid #000; border-bottom: 1px solid #000;} .search_container{ position: relative; box-sizing: border-box;border: 2px solid #3879D9;display: block; padding: 3px 10px; border-radius: 3px; height: 2.3em; width: 265px; overflow: hidden;} .search_container input[type="text"]{border: none; height: 2.0em;} .search_container input[type="text"]:focus {outline: 0;} .search_container input[type="submit"]{ cursor: pointer; font-family: FontAwesome; border: none; background: #3879D9; color: #fff; position: absolute; width: 3.5em; height: 3.0em; right:0px; top: -5px; outline : none;} .header0303{display:flex;} .iconmenu{text-align: center; padding-left: 24px;} .iconmenu p{color: #ababab;} .header0304{ width: 355px;}
試したこと
margin: 0 auto;
補足情報(FW/ツールのバージョンなど)
回答1件
あなたの回答
tips
プレビュー