質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
div

HTMLの<div>タグです。<div>要素は特に意味を持っていません。ひとかたまりのコンテンツに使用されるか、(セマンティックとして)他の要素では記述できないコンテンツに使用されることが多いです。

文字コード

文字コードとは、文字や記号をコンピュータ上で使用するために用いられるバイト表現を指します。

HTML

HTMLとは、ウェブ上の文書を記述・作成するためのマークアップ言語のことです。文章の中に記述することで、文書の論理構造などを設定することができます。ハイパーリンクを設定できるハイパーテキストであり、画像・リスト・表などのデータファイルをリンクする情報に結びつけて情報を整理します。現在あるネットワーク上のほとんどのウェブページはHTMLで作成されています。

CSS

CSSはXMLやHTMLで表現した色・レイアウト・フォントなどの要素を指示する仕様の1つです。

CSSフレームワーク

CSSフレームワークは、Webページのスタイルを指定する言語であるCSSを容易に構築するためのツールです。ツイッター社が開発した「Bootstrap」や段組レイアウトが可能な「Foundation」など様々なCSSフレームワークがあります。

Q&A

解決済

1回答

1144閲覧

html css のコーティング ナビバーに関して

yuuman

総合スコア5

div

HTMLの<div>タグです。<div>要素は特に意味を持っていません。ひとかたまりのコンテンツに使用されるか、(セマンティックとして)他の要素では記述できないコンテンツに使用されることが多いです。

文字コード

文字コードとは、文字や記号をコンピュータ上で使用するために用いられるバイト表現を指します。

HTML

HTMLとは、ウェブ上の文書を記述・作成するためのマークアップ言語のことです。文章の中に記述することで、文書の論理構造などを設定することができます。ハイパーリンクを設定できるハイパーテキストであり、画像・リスト・表などのデータファイルをリンクする情報に結びつけて情報を整理します。現在あるネットワーク上のほとんどのウェブページはHTMLで作成されています。

CSS

CSSはXMLやHTMLで表現した色・レイアウト・フォントなどの要素を指示する仕様の1つです。

CSSフレームワーク

CSSフレームワークは、Webページのスタイルを指定する言語であるCSSを容易に構築するためのツールです。ツイッター社が開発した「Bootstrap」や段組レイアウトが可能な「Foundation」など様々なCSSフレームワークがあります。

0グッド

0クリップ

投稿2020/04/18 02:50

前提・実現したいこ

navを作成しています。
navのboxの中に文字を入れたい。

途中ですが、liの文字がdiv boxの中からはみ出ます。

発生している問題・エラーメッセージ

該当のソースコード

<!-- ここからnavbar --> <nav class="h-nav"> <ul class="h-menu"> <li class="h-list"> <a href="index.html"> <div class="h-box active"> <div class="h-top"> ホーム </div> <div class="h-bottom"> HOME </div> </div> </a> </li> <li class="h-list"> <a href="company.html"> <div class="h-box"> <div class="h-top"> 会社概要 </div> <div class="h-bottom"> COMPANY </div> </div> </a> </li> <li class="h-list"> <a href="service.html"> <div class="h-box"> <div class="h-top"> サービス </div> <div class="h-bottom"> SERVICE </div> </div> </a> </li> <li class="h-list"> <a href="recrit.html"> <div class="h-box"> <div class="h-top"> 採用情報 </div> <div class="h-bottom"> RECRIT </div> </div> </a> </li> <li class="h-list"> <a href="link.html"> <div class="h-box"> <div class="h-top"> リンク </div> <div class="h-bottom"> LINK </div> </div> </a> </li> <li class="h-list"> <a href="contact.html"> <div class="h-box"> <div class="h-top"> お問い合わせ </div> <div class="h-bottom"> CONTACT </div> </div> </a> </li> </ul> </nav> <!-- ここまでnavbar --> ーーーーーーーーーーーーーーーーーーーーーーーーーーーー /* =================== ボディー ======================*/ body { background: #d2d2d2; font-family: "ヒラギノ角ゴ Pro W3", "Hiragino Kaku Gothic Pro", "メイリオ", Meiryo, Osaka, "MS Pゴシック", "MS PGothic", sans-serif; color: #666666; font-size: 15px; } /* =================== コンテナー ======================*/ #container { border-top: 5px solid #0e36ca; width: 1200px; background: #fff; margin: 0 auto; } /* =================== ヘッダー ======================*/ div.h-logo img { width: 300px; margin-top: 36px; margin-left: 4%; margin-bottom: 30px; } /* =================== ナビバー ======================*/ .h-nav { border-top: 1px solid #d2d2d2; } .h-menu { letter-spacing: -.4em; } .h-list { display: inline-block; width: calc(100%/6); position: relative; letter-spacing: normal; height: 64px; border-right: 1px solid #d2d2d2; box-sizing: border-box; vertical-align: bottom; } .h-list:hover .h-top { color: #0e36ca; } .h-list:hover { background-color: #e6ebfa; } .h-list:hover .h-box:before { content: ""; width: 3px; height: 100%; position: absolute; background-color: #0e36ca; left: 4px; } .h-box { position: absolute; top: 50%; left: 50%; transform: perspective(-50%, -50%); width: 90%; text-align: center; } .h-top { font-size: 15px; color: #666666; margin-bottom: 4px; } .h-bottom { font-size: 10px; color: #eaeaea; text-align: center; } .active { background: #e6ebfa; } .active .h-box:before { content: ""; width: 3px; height: 100%; position: absolute; background-color: #0e36ca; left: 4px; } .active .h-top { color: #0e36ca; } .h-image { max-width: 100%; height: auto; } /* =================== メイン ======================*/ #contents { clear: both; overflow: hidden; padding: 3%; } .main { float: left; width: 75%; } section { /* clear: both; */ display: block; } section h2 { clear: both; background-color: #0e36ca; font-size: 18px; color: #fff; border-radius: 4px; padding: 10px 20px; margin-bottom: 20px; } section h2::first-letter { border-left: 3px solid #8e9eef; padding-left: 16px; } section h3 { clear: both; margin-bottom: 20px; font-size: 18px; padding: 6px 20px; background-color: rgb(231,231,231); border-radius: 4px; border: 1px solid #666666; } section dl { padding-left: 20px; padding-right: 20px; margin-bottom: 20px; } .date { padding-top: 7px; padding-bottom: 7px; float: left; color: #0e36ca; letter-spacing: 0.1em; width: 9em; } section dd { padding-top: 7px; padding-bottom: 7px; padding-left: 9em; border-bottom: 1px solid #ccc; } .m-log { padding: 0 20px 15px; text-align: right; margin-bottom: 40px; } .m-log a { color: #666666; } .m-logo a:hover { color: #0e36ca; } .color1 { color: red; } .m-section p { padding: 0 20px 15px; line-height: 2em; } .ta1, .ta1 td, .ta1 th { border: 1px solid #ccc; padding: 10px 15px; word-break: break-all; } tbody { display: table-row-group; vertical-align: middle; border-color: inherit; } .ta1 { width: 100%; margin: 0 auto 20px; } table { border-collapse: collapse; font-size: 100%; border-spacing: 0; } tr { display: table-row; vertical-align: inherit; border-color: inherit; } .ta1 th { width: 140px; text-align: center; font-weight: normal; } .ta1 .th { width: auto; text-align: left; } .ta1 th a:hover { color: #0e36ca; text-decoration: none; transition: 0.5s; } th .d { } td { display: table-cell; vertical-align: inherit; } .m-section p a { color: #666666; } .main .list { position: relative; overflow: hidden; margin-bottom: 20px; border: 1px sorid #ccc; padding: 20px; background-color: #eee; border: 1px solid #eaeaea; } .main .list a { overflow: hidden; display: block; text-decoration: none; margin: -20px; padding: 20px; background: #eee; } .main .list img { width: 30%; float: left; margin-right: 10px; } .main .list h4 { font-size: 18px; color: #0e36ca; } .main .list a:hover { background: #fff; color: #0e36ca; } .bold { font-weight: bold; } .ws { width: 50%; } .wl { width: 96%; } .c { text-align: center; } .main input[type="submit"].btn, .main input[type="button"].btn, .main input[type="reset"].btn { padding: 5px 10px; border: 1px solid #ccc; font-size: 15px; border-radius: 3px; background: linear-gradient(#fff, #eee); } /* =================== サイドバー ======================*/ .side { float: right; width: 25%; } /* .sub { float: right; width: 25%; } */ .sub .box { border: 1px solid #d2d2d2; padding: 10px; margin-bottom: 20px; background: #eaeaea; } .sub h2 { padding: 15px 10px; background-color: #eee; border-bottom: 1px solid #d2d2d2; border-top: 5px solid #0e36ca; font-weight: bold; color: #666666; } .sub ul li a { text-decoration: none; display: block; padding: 5px 10px; border-bottom: 1px solid #d2d2d2; } .sub ul li a:hover { color: #0e36ca; } a { color: #666666; transition: 0.5s; } .submenu { margin-bottom: 20px; } figure img { float: left; width: 20%; margin-right: 5px; } .sub .list { position: relative; overflow: hidden; font-size: 11px; line-height: 1.2; margin-bottom: 10px; padding-bottom: 10px; border-bottom: 1px solid #d2d2d2; } .sub .list h4 { color: #0e36ca; } .list a { text-decoration: none; } .c { text-align: center; } strong { font-weight: bold; } .mini { font-size: 11px; display: inline-block; line-height: 1.5; } /* =================== フッター ======================*/ .footer { clear: both; text-align: center; padding: 10px 0; background: #0e36ca; color: #fff; line-height: 1.2; } footer small { font-size: smaller; } footer a { text-decoration: none; color: #fff; } footer .pr { display: block; font-size: 80%; }

試したこと

overflow や padding で調整してみるも何か上手くいきませんでした。

補足情報(FW/ツールのバージョンなど)

vscodeを使用してます。
html5、css3利用です。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

hatena19

2020/04/18 03:35

HTMLコードとCSSコードは別ブロックにしてください。また、言語名も指定してください。 下記のような感じです。 ```html HTMLコードを記述 ``` ```css CSSコードを記述 ```
guest

回答1

0

ベストアンサー

h-box内で水平位置と垂直位置を中央配置したいということですよね。
perspective ではなくtranslate ではないでしょうか。

css

1.h-box { 2 position: absolute; 3 top: 50%; 4 left: 50%; 5/* transform: perspective(-50%, -50%); これを下記に修正*/ 6 transform: translate(-50%, -50%); 7 width: 90%; 8 text-align: center; 9}

投稿2020/04/18 03:40

hatena19

総合スコア33699

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

yuuman

2020/04/18 04:51

ありがとうございます。 早速試したら正しい位置になりました。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問