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

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

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

jQueryは、JavaScriptライブラリのひとつです。 簡単な記述で、JavaScriptコードを実行できるように設計されています。 2006年1月に、ジョン・レシグが発表しました。 jQueryは独特の記述法を用いており、機能のほとんどは「$関数」や「jQueryオブジェクト」のメソッドとして定義されています。

Sass

Sassは、プログラミング風のコードでCSSを生成できるスタイルシート言語です。 scss ファイルを、変換(コンパイル)してCSSファイルを作成します。

HTML

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

CSS

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

Q&A

1回答

885閲覧

指定していないはずのpaddingが反映されている。

duu

総合スコア1

jQuery

jQueryは、JavaScriptライブラリのひとつです。 簡単な記述で、JavaScriptコードを実行できるように設計されています。 2006年1月に、ジョン・レシグが発表しました。 jQueryは独特の記述法を用いており、機能のほとんどは「$関数」や「jQueryオブジェクト」のメソッドとして定義されています。

Sass

Sassは、プログラミング風のコードでCSSを生成できるスタイルシート言語です。 scss ファイルを、変換(コンパイル)してCSSファイルを作成します。

HTML

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

CSS

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

0グッド

0クリップ

投稿2021/03/05 22:41

編集2021/03/06 13:16

前提・実現したいこと

HTML/CSSでのコーディング中、
Sassでスタイルをつけていたのですが、Sass上でもコンパイルされたCSS上でも、記載されていないpaddingがブラウザ上だとかかってしまっている。
.header__title になぜかかかってしまったpaddingを解除したい。

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

エラーは発生していないようです

該当のソースコード

scss

1@mixin header-title($width){ 2 color: $white; 3 height: $width; 4 display: flex; 5 flex-direction: column; 6 align-items: flex-end; 7 justify-content: center; 8} 9 10~~~~~ 11 12.header__title{ 13 14 @include header-title(100vh); 15 &-about{ 16 @include header-title(63vh); 17 } 18 19 &--subtitle{ 20 font-family: $fontY; 21 font-family: $fontM; 22 font-size: 2rem; 23 line-height: 1; 24 font-weight: bold; 25 } 26 &--maintitle{ 27 font-family: $fontM; 28 font-size: 7.2rem; 29 line-height: (86 / 72); 30 font-weight: bold; 31 32 } 33 } 34

イメージ説明

scss

1@charset "UTF-8"; 2 3/* 関数 */ 4$white:#ffffff; 5$black:#222; 6$gray:#525252; 7$back:#F2F2F2; 8$fontM: 'Montserrat', sans-serif; 9$fontS: 'Noto Sans JP', sans-serif; 10$fontY:"游ゴシック体", YuGothic, "游ゴシック Medium", "Yu Gothic Medium", "游ゴシック", "Yu Gothic", sans-serif; 11$textMargin:30px 0; 12 13@mixin padding($padding){ 14 padding-left: $padding; 15 padding-right: $padding; 16} 17 18@mixin header-image($width,$height){ 19 width: $width; 20 height: $height; 21 margin:0 calc(50% - 50vw); 22 position: absolute; 23 top: 0; 24 z-index: -2; 25} 26@mixin header-black($width,$height){ 27 background:$black; 28 width: $width; 29 height: $height; 30 position: absolute; 31 right: 0; 32 top: 0; 33 z-index: -3; 34} 35 36@mixin header-title($width){ 37 color: $white; 38 height: $width; 39 display: flex; 40 flex-direction: column; 41 align-items: flex-end; 42 justify-content: center; 43} 44 45 46@mixin description($weight){ 47 font-family: $fontY; 48 font-weight: $weight; 49 font-size: 1.6rem; 50 padding-top: 17px; 51 padding-bottom: 18px; 52 53} 54/* 共通 */ 55html{ 56 font-size: 62.5%; 57 scroll-behavior: smooth; 58} 59 60body *{ 61 box-sizing: border-box; 62 63} 64body{ 65 &::after{ 66 content: ''; 67 position: fixed; 68 top: 0; 69 left: 0; 70 width: 100%; 71 height: 100%; 72 background-color:#fff; /* 背景カラー */ 73 z-index: 9999; /* 一番手前に */ 74 pointer-events: none; /* 他の要素にアクセス可能にするためにポインターイベントは無効に */ 75 opacity: 0; /* 初期値 : 透過状態 */ 76 -webkit-transition: opacity .4s linear; /* アニメーション時間は 0.8秒 */ 77 transition: opacity .4s linear; 78 } 79 &.fadeout::after{ 80 opacity:1; 81 -webkit-transition: opacity .4s linear; /* アニメーション時間は 0.8秒 */ 82 transition: opacity .4s linear; 83 } 84} 85section{ 86 @include padding(170px); 87 font-family: $fontM; 88 font-family: $fontS; 89 font-family: $fontY; 90} 91 92.read_more{ 93 width: 160px; 94 height: 36px; 95 background-color: $black; 96 display: flex; 97 justify-content: center; 98 align-items: center; 99 text-align: center; 100 a{ 101 border: none; 102 display: block; 103 width: 100%; 104 color: $white; 105 background-color: $black; 106 text-decoration: none; 107 font-style: $fontM; 108 font-weight: bold; 109 } 110 111} 112 113h2{ 114 font-family: $fontM; 115 font-weight: bold; 116 font-size: 3.2rem; 117 line-height: (94 / 32); 118} 119 120h3{ 121 font-size: 2.4rem; 122 font-weight: bold; 123 font-family: $fontY; 124} 125p{ 126 font-size: 1.6rem; 127} 128 129li{ 130 list-style: none; 131} 132 133//HEADER 134#header{ 135 margin: 0 calc(50% - 50vw); 136 // height: 100vh; 137 position: relative; 138 .header__background{ 139 background:url(../images/kv-img2x.png)no-repeat center/cover; 140 @include header-image(76vw,86vh ); 141 142 &-about{ 143 background: url(../images/heading-img@2x.png)no-repeat center/cover; 144 @include header-image(76vw,52vh ); 145 } 146 147 } 148 .header__background--black{ 149 @include header-black(50%,100vh ); 150 &-about{ 151 @include header-black(50%,63vh ); 152 } 153 } 154 .header__background--gray{ 155 width: 100vw; 156 height: 100vh; 157 background-color: rgba($color: $black, $alpha: 0.6); 158 display: none; 159 position: absolute; 160 z-index: -1; 161 162 } 163 .header__title{ 164 165 @include header-title(100vh); 166 &-about{ 167 @include header-title(63vh); 168 } 169 170 &--subtitle{ 171 font-family: $fontY; 172 font-family: $fontM; 173 font-size: 2rem; 174 line-height: 1; 175 font-weight: bold; 176 } 177 &--maintitle{ 178 font-family: $fontM; 179 font-size: 7.2rem; 180 line-height: (86 / 72); 181 font-weight: bold; 182 183 } 184 } 185 .header__nav{ 186 display: flex; 187 width: 100vw; 188 justify-content: space-between; 189 align-items: center; 190 padding: 30px 58px 30px; 191 position: fixed; 192 z-index: 1; 193 194 &.withColor{ 195 transition: all 0.3s ease; 196 background-color:rgba($color: $black, $alpha: 0.9) 197 } 198 199 &--logo.gray{ 200 opacity: 0.4; 201 } 202 203 204 &--menu{ 205 display: flex; 206 align-items: center; 207 color: $white; 208 z-index: 99; 209 cursor: pointer; 210 &-bar{ 211 width: 61px; 212 height: 13px; 213 display: flex; 214 justify-content: center; 215 align-items: center; 216 z-index: 90; 217 218 219 &,&::before,&::after{ 220 content: ''; 221 display: block; 222 height: 3px; 223 width: 25px; 224 border-radius: 3px; 225 background-color: $white; 226 position: absolute; 227 } 228 &::before{ 229 bottom: 5px; 230 } 231 &::after{ 232 top: 5px; 233 } 234 } 235 p{ 236 margin-left: 39px; 237 font-family: $fontM; 238 font-size: 1rem; 239 font-weight: bold; 240 } 241 242 243 &.open .header__nav--menu-bar{ 244 background-color: rgba(255, 255, 255, 0); 245 } 246 &.open .header__nav--menu-bar::before{ 247 transform: rotate(45deg); 248 bottom: 0; 249 } 250 &.open .header__nav--menu-bar::after{ 251 transform: rotate(-45deg); 252 top: 0; 253 } 254 } 255 256 257 } 258} 259 260 261 262 263//NAVIGATION 264 .header__hamburger{ 265 width: 520px; 266 height: 100vh; 267 background-color:rgba($color: $black, $alpha: 0.9); 268 position: absolute; 269 right: 0; 270 top: 0; 271 display: flex; 272 justify-content: center; 273 align-items: center; 274 transform: translateX(100%); 275 flex-direction: column; 276 transition: all 0.4s ease; 277 z-index: 0; 278 position: fixed; 279 img{ 280 margin-bottom: 40px; 281 } 282 &--menu{ 283 text-align: center; 284 li{ 285 margin-bottom: 30px; 286 &:last-of-type{ 287 margin-bottom: 0; 288 } 289 a{ 290 color: $white; 291 font-size: 2rem; 292 line-height: 1; 293 font-weight: bold; 294 text-decoration: none; 295 296 } 297 } 298 } 299 &.open{ 300 transition: all 0.4s ease; 301 transform: translateX(0); 302 } 303 } 304 305//BACKGROUND 306.background{ 307 background: linear-gradient(180deg,$white 0%,$white 50%,$back 50%,$back 100%); 308 margin: 0 calc(50% - 50vw); 309 padding-bottom: 80px; 310 width: 100vw; 311 display: grid; 312 grid-template-areas: 313 "about about" 314 "works culture"; 315 316

試したこと

・別のmixinを指定してみても、解除されない。
・paddingを上書きしてみても指定されない。

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

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

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

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

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

Lhankor_Mhy

2021/03/06 00:41

スクリーンショットを拝見すると、style.scss:42 と style.scss:184 の二か所にスタイルがあるようですが、これは実際のSCSSファイルだとどうなっていますか? 見た感じ、184行目がご提示のCSSのように見えます。
duu

2021/03/06 13:17

追記依頼ありがとうございます。 実際のファイルだと、42行目までに mixin を設定して、184行目のところで include しております。 mixin内でpaddingを上書きしても反応しなかったです。
Lhankor_Mhy

2021/03/08 01:14

ご提示のコードを試してみましたが、再現しませんでした。 @mixin padding() を空にして再コンパイルするとどうなりますか?
guest

回答1

0

下みたいにしたらと回答をすると他の方に怒られるだろうか?
通常であればstyle.scssを探してもとのpaddingの記述を消すべきだとは思うけども。
どうしても記述が探せない場合にはこれするしかないよねぇ。
と言っても、見つからない場合は稀だけどね。

CSS

1#header .header__title { 2 padding: 0 !important; 3}

投稿2021/03/06 03:18

退会済みユーザー

退会済みユーザー

総合スコア0

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

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

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだベストアンサーが選ばれていません

会員登録して回答してみよう

アカウントをお持ちの方は

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

ただいまの回答率
85.48%

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

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

質問する

関連した質問