teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

4

PC版の画像の追記

2020/09/09 20:14

投稿

takawork
takawork

スコア95

title CHANGED
File without changes
body CHANGED
@@ -1,9 +1,12 @@
1
+ PC版
2
+ ![イメージ説明](447a11588f14a83d3aad5d70b3a7c2f7.png)
3
+ スマホ版
1
4
  ![![イメージ説明](a667573d88f4b6f957a8bad1a182c9e1.png)](30c23bc01697a24f49c2e392c836fc7b.png)
2
5
 
3
6
  画像はスマホサイズにした時の画面です。
4
7
  ヘッダーの下にメインコンテンツをおきたいのですが、大きめの隙間が出来てしまいます。
5
- 大きさ調べると、「あ」のころま.topbarbgスがあ検証モードで出たので、
8
+ 検証モードで隙間ると、topbarbg表示されたので、PC版のロゴの背景のボックス要素?消えていにんだ思います。
6
- それをdisplay:none;で消したらメニューの方が消えてしまいました。
9
+ 自分ではdisplay:none;で消したらスマホ版メニューが消えてしまいました。
7
10
  どうすればヘッダーの下にディスプレイをおくことが出来ますでしょうか?
8
11
  ブートストラップのグリッドで作成しています。よろしくお願いします。
9
12
  ```

3

全体のcssの追記

2020/09/09 20:14

投稿

takawork
takawork

スコア95

title CHANGED
File without changes
body CHANGED
@@ -113,6 +113,85 @@
113
113
 
114
114
  }());
115
115
  ```
116
+ 全体のcssです。
117
+ ```
118
+ body {
119
+ background-color: #f5f5f5;
120
+ }
121
+
122
+ .headerwp {
123
+ max-width: 1200px;
124
+ margin: 0 auto;
125
+ padding: 0px;
126
+ min-width: 320px;
127
+ }
128
+
129
+ .topbarbg {
130
+ width: 100%;
131
+ display: block;
132
+ min-height: 214px;
133
+ padding-top: 0px;
134
+ background: url(../images/topbg.jpg) top center no-repeat;
135
+ box-shadow: 0 0 20px rgba(0, 0, 0, .3);
136
+ }
137
+
138
+ .desktoplogo {
139
+ padding: 49px 0px;
140
+ margin: 0 auto;
141
+ text-align: center;
142
+ }
143
+ .desktoplogo img{
144
+ width:300px;
145
+ }
146
+
147
+
148
+
149
+
150
+ @media only screen and (min-width: 230px) and (max-width:991px) {
151
+ .desktoplogo {
152
+ display: none;
153
+ }
154
+
155
+ .topbarbg {
156
+ background: none;
157
+ box-shadow: none;
158
+ }
159
+
160
+ .swichermainbx {
161
+ width: 96%;
162
+ margin: 0% 2%;
163
+ display: block;
164
+ background-color: rgba(255, 255, 255, 0.3);
165
+ padding: 15px 25px;
166
+ border-radius: 14px;
167
+ }
168
+
169
+ .swichermainleft {
170
+ width: 98%;
171
+ margin: 1% 1%;
172
+ }
173
+
174
+ .swichermainright {
175
+ width: 98%;
176
+ margin: 1% 1%;
177
+ }
178
+
179
+ .wscolorcode {
180
+ width: 12.5%;
181
+ }
182
+
183
+ .swichertxt {
184
+ display: none;
185
+ }
186
+
187
+ .swichertxt02 span {
188
+ display: none;
189
+ }
190
+
191
+ }
192
+ ```
193
+
194
+
116
195
  ↓メニューだけのcssです。
117
196
  css1つ目
118
197
  https://harigami.jp/cd?hsh=2acb3522-665d-4853-a09f-05babd9500af

2

cssとjqueryの追加

2020/09/09 19:25

投稿

takawork
takawork

スコア95

title CHANGED
File without changes
body CHANGED
@@ -39,79 +39,82 @@
39
39
  </div>
40
40
  ```
41
41
  ```
42
- body {
43
- background-color: #f5f5f5;
42
+ /* global jQuery */
44
- }
43
+ /* global document */
45
44
 
46
- .headerwp {
45
+ jQuery(function () {
47
- max-width: 1200px;
46
+ 'use strict';
48
- margin: 0 auto;
49
- padding: 0px;
50
- min-width: 320px;
51
- }
52
47
 
53
- .topbarbg {
54
- width: 100%;
55
- display: block;
56
- min-height: 214px;
57
- padding-top: 0px;
58
- background: url(../images/topbg.jpg) top center no-repeat;
48
+ document.addEventListener("touchstart", function () {}, false);
59
- box-shadow: 0 0 20px rgba(0, 0, 0, .3);
49
+ jQuery(function () {
60
- }
61
50
 
62
- .desktoplogo {
63
- padding: 49px 0px;
64
- margin: 0 auto;
65
- text-align: center;
51
+ jQuery('body').wrapInner('<div class="wsmenucontainer" />');
66
- }
67
- .desktoplogo img{
52
+ jQuery('<div class="overlapblackbg"></div>').prependTo('.wsmenu');
68
- width:300px;
69
- }
70
53
 
54
+ jQuery('#wsnavtoggle').click(function () {
55
+ jQuery('body').toggleClass('wsactive');
56
+ });
71
57
 
58
+ jQuery('.overlapblackbg').click(function () {
59
+ jQuery("body").removeClass('wsactive');
60
+ });
72
61
 
62
+ jQuery('.wsmenu > .wsmenu-list > li').has('.sub-menu').prepend('<span class="wsmenu-click"><i class="wsmenu-arrow"></i></span>');
63
+ jQuery('.wsmenu > .wsmenu-list > li').has('.wsmegamenu').prepend('<span class="wsmenu-click"><i class="wsmenu-arrow"></i></span>');
73
64
 
65
+ jQuery('.wsmenu-click').click(function () {
66
+ jQuery(this).toggleClass('ws-activearrow')
74
- @media only screen and (min-width: 230px) and (max-width:991px) {
67
+ .parent().siblings().children().removeClass('ws-activearrow');
75
- .desktoplogo {
68
+ jQuery(".wsmenu > .wsmenu-list > li > .sub-menu, .wsmegamenu").not(jQuery(this).siblings('.wsmenu > .wsmenu-list > li > .sub-menu, .wsmegamenu')).slideUp('slow');
76
- display: none;
69
+ jQuery(this).siblings('.sub-menu').slideToggle('slow');
70
+ jQuery(this).siblings('.wsmegamenu').slideToggle('slow');
77
- }
71
+ });
78
72
 
79
- .topbarbg {
80
- background: none;
81
- box-shadow: none;
73
+ jQuery('.wsmenu > .wsmenu-list > li > ul > li').has('.sub-menu').prepend('<span class="wsmenu-click02"><i class="wsmenu-arrow"></i></span>');
82
- }
74
+ jQuery('.wsmenu > .wsmenu-list > li > ul > li > ul > li').has('.sub-menu').prepend('<span class="wsmenu-click02"><i class="wsmenu-arrow"></i></span>');
83
-
84
75
 
85
- .swichermainbx {
86
- width: 96%;
87
- margin: 0% 2%;
88
- display: block;
89
- background-color: rgba(255, 255, 255, 0.3);
76
+ jQuery('.wsmenu-click02').click(function () {
90
- padding: 15px 25px;
91
- border-radius: 14px;
77
+ jQuery(this).children('.wsmenu-arrow').toggleClass('wsmenu-rotate');
78
+ jQuery(this).siblings('li > .sub-menu').slideToggle('slow');
92
- }
79
+ });
93
80
 
94
- .swichermainleft {
81
+ jQuery(window).on('resize', function () {
95
- width: 98%;
96
- margin: 1% 1%;
97
- }
98
82
 
99
- .swichermainright {
100
- width: 98%;
101
- margin: 1% 1%;
102
- }
83
+ if (jQuery(window).outerWidth() < 992) {
84
+ jQuery('.wsmenu').css('height', jQuery(this).height() + "px");
85
+ jQuery('.wsmenucontainer').css('min-width', jQuery(this).width() + "px");
86
+ } else {
87
+ jQuery('.wsmenu').removeAttr("style");
88
+ jQuery('.wsmenucontainer').removeAttr("style");
89
+ jQuery('body').removeClass("wsactive");
90
+ jQuery('.wsmenu > .wsmenu-list > li > .wsmegamenu, .wsmenu > .wsmenu-list > li > ul.sub-menu, .wsmenu > .wsmenu-list > li > ul.sub-menu > li > ul.sub-menu, .wsmenu > .wsmenu-list > li > ul.sub-menu > li > ul.sub-menu > li > ul.sub-menu').removeAttr("style");
91
+ jQuery('.wsmenu-click').removeClass("ws-activearrow");
92
+ jQuery('.wsmenu-click02 > i').removeClass("wsmenu-rotate");
93
+ }
103
94
 
104
- .wscolorcode {
105
- width: 12.5%;
106
- }
95
+ });
107
96
 
108
- .swichertxt {
97
+ jQuery(window).trigger('resize');
109
- display: none;
110
- }
111
98
 
112
- .swichertxt02 span {
113
- display: none;
114
- }
99
+ });
115
100
 
101
+ //Mobile Search Box
102
+ jQuery(window).on("load", function () {
103
+ jQuery('.wsmobileheader .wssearch').on("click", function () {
104
+ jQuery(this).toggleClass("wsopensearch");
116
- }
105
+ });
106
+ jQuery("body, .wsopensearch .wscloseicon").on("click", function () {
107
+ jQuery(".wssearch").removeClass('wsopensearch');
108
+ });
109
+ jQuery(".wssearch, .wssearchform form").on("click", function (e) {
110
+ e.stopPropagation();
111
+ });
112
+ });
113
+
114
+ }());
117
- ```
115
+ ```
116
+ ↓メニューだけのcssです。
117
+ css1つ目
118
+ https://harigami.jp/cd?hsh=2acb3522-665d-4853-a09f-05babd9500af
119
+ css2つ目
120
+ https://harigami.jp/cd?hsh=021f80bb-7d65-4621-a21d-1e6c55672288

1

ブートストラップを使用してることの説明の追記。

2020/09/09 18:44

投稿

takawork
takawork

スコア95

title CHANGED
File without changes
body CHANGED
@@ -5,7 +5,7 @@
5
5
  大きさを調べると、「あ」のところまでに、.topbarbgクラスがあると検証モードで出たので、
6
6
  それをdisplay:none;で消したらメニューの方が消えてしまいました。
7
7
  どうすればヘッダーの下にディスプレイをおくことが出来ますでしょうか?
8
- よろしくお願いします。
8
+ ブートストラップのグリッドで作成しています。よろしくお願いします。
9
9
  ```
10
10
  <!-- レスポンシブ後のモバイルヘッダー -->
11
11
  <div class="wsmobileheader clearfix">