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

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

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

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

CSS

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

Q&A

3回答

2564閲覧

レスポンシブデザインのメニューの幅のサイズが変更できない

sutosi

総合スコア27

HTML

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

CSS

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

0グッド

0クリップ

投稿2017/09/24 12:21

こちらのサイトを参考にして、ウィンドウ幅が小さくなったときスマホサイト用にメニューが出る設定をしたのですが幅が表示されるときのウィンドウ枠の数値をjquery.meanmenu.jsのmeanScreenWidthで設定できるはずなのですが反映されません
どうすれば反映されますでしょうか、ご教授お願いいたします。
https://share-life.biz/web/responsive-menu/

jquery.meanmenu.js

1(function ($) { 2 "use strict"; 3 $.fn.meanmenu = function (options) { 4 var defaults = { 5meanMenuTarget: jQuery(this), // Target the current HTML markup you wish to replace 6meanMenuContainer: 'body', // Choose where meanmenu will be placed within the HTML 7meanMenuClose: "X", // single character you want to represent the close menu button 8meanMenuCloseSize: "18px", // set font size of close button 9meanMenuOpen: "<span /><span /><span />", // text/markup you want when menu is closedmeanRevealPosition: "right", // left right or center positions 10meanRevealPositionDistance: "0", // Tweak the position of the menu 11meanRevealColour: "", // override CSS colours for the reveal background 12meanScreenWidth: "480", // set the screen width you want meanmenu to kick in at 13meanNavPush: "", // set a height here in px, em or % if you want to budge your layout now the navigation is missing. 14meanShowChildren: true, // true to show children in the menu, false to hide them 15meanExpandableChildren: true, // true to allow expand/collapse children 16meanExpand: "+", // single character you want to represent the expand for ULs 17meanContract: "-", // single character you want to represent the contract for ULs 18meanRemoveAttrs: false, // true to remove classes and IDs, false to keep them 19onePage: false, // set to true for one page sites 20meanDisplay: "block", // override display method for table cell based layouts e.g. table-cell 21removeElements: "" // set to hide page elements 22 }; 23 options = $.extend(defaults, options); 24 25 // get browser width 26 var currentWidth = window.innerWidth || document.documentElement.clientWidth; 27 28 return this.each(function () { 29var meanMenu = options.meanMenuTarget; 30var meanContainer = options.meanMenuContainer; 31var meanMenuClose = options.meanMenuClose; 32var meanMenuCloseSize = options.meanMenuCloseSize; 33var meanMenuOpen = options.meanMenuOpen; 34var meanRevealPosition = options.meanRevealPosition; 35var meanRevealPositionDistance = options.meanRevealPositionDistance; 36var meanRevealColour = options.meanRevealColour; 37var meanScreenWidth = options.meanScreenWidth; 38var meanNavPush = options.meanNavPush; 39var meanRevealClass = ".meanmenu-reveal"; 40var meanShowChildren = options.meanShowChildren; 41var meanExpandableChildren = options.meanExpandableChildren; 42var meanExpand = options.meanExpand; 43var meanContract = options.meanContract; 44var meanRemoveAttrs = options.meanRemoveAttrs; 45var onePage = options.onePage; 46var meanDisplay = options.meanDisplay; 47var removeElements = options.removeElements; 48 49//detect known mobile/tablet usage 50var isMobile = false; 51if ( (navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)) || (navigator.userAgent.match(/iPad/i)) || (navigator.userAgent.match(/Android/i)) || (navigator.userAgent.match(/Blackberry/i)) || (navigator.userAgent.match(/Windows Phone/i)) ) { 52isMobile = true; 53} 54 55if ( (navigator.userAgent.match(/MSIE 8/i)) || (navigator.userAgent.match(/MSIE 7/i)) ) { 56// add scrollbar for IE7 & 8 to stop breaking resize function on small content sites 57 jQuery('html').css("overflow-y" , "scroll"); 58} 59 60var meanRevealPos = ""; 61var meanCentered = function() { 62if (meanRevealPosition === "center") { 63var newWidth = window.innerWidth || document.documentElement.clientWidth; 64var meanCenter = ( (newWidth/2)-22 )+"px"; 65meanRevealPos = "left:" + meanCenter + ";right:auto;"; 66if (!isMobile) { 67jQuery('.meanmenu-reveal').css("left",meanCenter); 68} else { 69jQuery('.meanmenu-reveal').animate({ 70left: meanCenter 71}); 72} 73} 74}; 75 76var menuOn = false; 77var meanMenuExist = false; 78 79if (meanRevealPosition === "right") { 80meanRevealPos = "right:" + meanRevealPositionDistance + ";left:auto;"; 81} 82if (meanRevealPosition === "left") { 83meanRevealPos = "left:" + meanRevealPositionDistance + ";right:auto;"; 84 } 85// run center function 86meanCentered(); 87 88// set all styles for mean-reveal 89var $navreveal = ""; 90var meanInner = function() { 91// get last class name 92if (jQuery($navreveal).is(".meanmenu-reveal.meanclose")) { 93$navreveal.html(meanMenuClose); 94} else { 95$navreveal.html(meanMenuOpen); 96} 97}; 98 99// re-instate original nav (and call this on window.width functions) 100var meanOriginal = function() { 101jQuery('.mean-bar,.mean-push').remove(); 102jQuery(meanContainer).removeClass("mean-container"); 103jQuery(meanMenu).css('display', meanDisplay); 104menuOn = false; 105meanMenuExist = false; 106jQuery(removeElements).removeClass('mean-remove'); 107}; 108 109// navigation reveal 110var showMeanMenu = function() { 111var meanStyles = "background:"+meanRevealColour+";color:"+meanRevealColour+";"+meanRevealPos; 112if (currentWidth <= meanScreenWidth) { 113jQuery(removeElements).addClass('mean-remove'); 114meanMenuExist = true; 115// add class to body so we don't need to worry about media queries here, all CSS is wrapped in '.mean-container' 116jQuery(meanContainer).addClass("mean-container"); 117jQuery('.mean-container').prepend('<div class="mean-bar"><a href="#nav" class="meanmenu-reveal" style="'+meanStyles+'">Show Navigation</a><nav class="mean-nav"></nav></div>'); 118//push meanMenu navigation into .mean-nav 119var meanMenuContents = jQuery(meanMenu).html(); 120jQuery('.mean-nav').html(meanMenuContents); 121 122// remove all classes from EVERYTHING inside meanmenu nav 123if(meanRemoveAttrs) { 124jQuery('nav.mean-nav ul, nav.mean-nav ul *').each(function() { 125// First check if this has mean-remove class 126if (jQuery(this).is('.mean-remove')) { 127jQuery(this).attr('class', 'mean-remove'); 128} else { 129jQuery(this).removeAttr("class"); 130} 131jQuery(this).removeAttr("id"); 132}); 133} 134 135// push in a holder div (this can be used if removal of nav is causing layout issues) 136jQuery(meanMenu).before('<div class="mean-push" />'); 137jQuery('.mean-push').css("margin-top",meanNavPush); 138 139jQuery(meanMenu).hide(); 140jQuery(".meanmenu-reveal").show(); 141 142// turn 'X' on or off 143jQuery(meanRevealClass).html(meanMenuOpen); 144$navreveal = jQuery(meanRevealClass); 145 146//hide mean-nav ul 147jQuery('.mean-nav ul').hide(); 148 149// hide sub nav 150if(meanShowChildren) { 151// allow expandable sub nav(s) 152if(meanExpandableChildren){ 153jQuery('.mean-nav ul ul').each(function() { 154if(jQuery(this).children().length){ 155jQuery(this,'li:first').parent().append('<a class="mean-expand" href="#" style="font-size: '+ meanMenuCloseSize +'">'+ meanExpand +'</a>'); 156} 157}); 158jQuery('.mean-expand').on("click",function(e){ 159e.preventDefault(); 160if (jQuery(this).hasClass("mean-clicked")) { 161jQuery(this).text(meanExpand); 162jQuery(this).prev('ul').slideUp(300, function(){}); 163} else { 164jQuery(this).text(meanContract); 165jQuery(this).prev('ul').slideDown(300, function(){}); 166} 167jQuery(this).toggleClass("mean-clicked"); 168}); 169} else { 170jQuery('.mean-nav ul ul').show(); 171} 172} else { 173jQuery('.mean-nav ul ul').hide(); 174} 175 176// add last class to tidy up borders 177jQuery('.mean-nav ul li').last().addClass('mean-last'); 178$navreveal.removeClass("meanclose"); 179jQuery($navreveal).click(function(e){ 180e.preventDefault(); 181if( menuOn === false ) { 182$navreveal.css("text-align", "center"); 183$navreveal.css("text-indent", "0"); 184$navreveal.css("font-size", meanMenuCloseSize); 185jQuery('.mean-nav ul:first').slideDown(); 186menuOn = true; 187} else { 188jQuery('.mean-nav ul:first').slideUp(); 189menuOn = false; 190} 191$navreveal.toggleClass("meanclose"); 192meanInner(); 193jQuery(removeElements).addClass('mean-remove'); 194}); 195 196// for one page websites, reset all variables... 197if ( onePage ) { 198jQuery('.mean-nav ul > li > a:first-child').on( "click" , function () { 199jQuery('.mean-nav ul:first').slideUp(); 200menuOn = false; 201jQuery($navreveal).toggleClass("meanclose").html(meanMenuOpen); 202}); 203} 204} else { 205meanOriginal(); 206} 207}; 208 209if (!isMobile) { 210// reset menu on resize above meanScreenWidth 211jQuery(window).resize(function () { 212currentWidth = window.innerWidth || document.documentElement.clientWidth; 213if (currentWidth > meanScreenWidth) { 214meanOriginal(); 215} else { 216meanOriginal(); 217} 218if (currentWidth <= meanScreenWidth) { 219showMeanMenu(); 220meanCentered(); 221} else { 222meanOriginal(); 223} 224}); 225} 226 227jQuery(window).resize(function () { 228// get browser width 229currentWidth = window.innerWidth || document.documentElement.clientWidth; 230 231if (!isMobile) { 232meanOriginal(); 233if (currentWidth <= meanScreenWidth) { 234showMeanMenu(); 235meanCentered(); 236} 237} else { 238meanCentered(); 239if (currentWidth <= meanScreenWidth) { 240if (meanMenuExist === false) { 241showMeanMenu(); 242} else { 243meanOriginal(); 244} 245 246}); 247 248// run main menuMenu function on load 249showMeanMenu(); 250}); 251 }; 252})(jQuery);

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

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

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

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

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

guest

回答3

0

追記3です

meanmenu.js

1 2/*! ####################################################################### 3 4 MeanMenu 2.0.7 5 -------- 6 7 To be used with jquery.meanmenu.js by Chris Wharton (http://www.meanthemes.com/plugins/meanmenu/) 8 9####################################################################### */ 10 11/* hide the link until viewport size is reached */ 12a.meanmenu-reveal { 13 display: none; 14} 15 16/* when under viewport size, .mean-container is added to body */ 17.mean-container .mean-bar { 18 float: left; 19 width: 100%; 20 position: relative; 21 background: #0c1923; 22 padding: 4px 0; 23 min-height: 42px; 24 z-index: 999999; 25} 26 27.mean-container a.meanmenu-reveal { 28 width: 22px; 29 height: 22px; 30 padding: 13px 13px 11px 13px; 31 position: absolute; 32 top: 0; 33 right: 0; 34 cursor: pointer; 35 color: #fff; 36 text-decoration: none; 37 font-size: 16px; 38 text-indent: -9999em; 39 line-height: 22px; 40 font-size: 1px; 41 display: block; 42 font-family: Arial, Helvetica, sans-serif; 43 font-weight: 700; 44} 45 46.mean-container a.meanmenu-reveal span { 47 display: block; 48 background: #fff; 49 height: 3px; 50 margin-top: 3px; 51} 52 53.mean-container .mean-nav { 54 float: left; 55 width: 100%; 56 background: #0c1923; 57 margin-top: 44px; 58} 59 60.mean-container .mean-nav ul { 61 padding: 0; 62 margin: 0; 63 width: 100%; 64 list-style-type: none; 65} 66 67.mean-container .mean-nav ul li { 68 position: relative; 69 float: left; 70 width: 100%; 71} 72 73.mean-container .mean-nav ul li a { 74 display: block; 75 float: left; 76 width: 90%; 77 padding: 1em 5%; 78 margin: 0; 79 text-align: left; 80 color: #fff; 81 border-top: 1px solid #383838; 82 border-top: 1px solid rgba(255,255,255,0.5); 83 text-decoration: none; 84 text-transform: uppercase; 85} 86 87.mean-container .mean-nav ul li li a { 88 width: 80%; 89 padding: 1em 10%; 90 border-top: 1px solid #f1f1f1; 91 border-top: 1px solid rgba(255,255,255,0.25); 92 opacity: 0.75; 93 filter: alpha(opacity=75); 94 text-shadow: none !important; 95 visibility: visible; 96} 97 98.mean-container .mean-nav ul li.mean-last a { 99 border-bottom: none; 100 margin-bottom: 0; 101} 102 103.mean-container .mean-nav ul li li li a { 104 width: 70%; 105 padding: 1em 15%; 106} 107 108.mean-container .mean-nav ul li li li li a { 109 width: 60%; 110 padding: 1em 20%; 111} 112 113.mean-container .mean-nav ul li li li li li a { 114 width: 50%; 115 padding: 1em 25%; 116} 117 118.mean-container .mean-nav ul li a:hover { 119 background: #252525; 120 background: rgba(255,255,255,0.1); 121} 122 123.mean-container .mean-nav ul li a.mean-expand { 124 margin-top: 1px; 125 width: 26px; 126 height: 32px; 127 padding: 12px !important; 128 text-align: center; 129 position: absolute; 130 right: 0; 131 top: 0; 132 z-index: 2; 133 font-weight: 700; 134 background: rgba(255,255,255,0.1); 135 border: none !important; 136 border-left: 1px solid rgba(255,255,255,0.4) !important; 137 border-bottom: 1px solid rgba(255,255,255,0.2) !important; 138} 139 140.mean-container .mean-nav ul li a.mean-expand:hover { 141 background: rgba(0,0,0,0.9); 142} 143 144.mean-container .mean-push { 145 float: left; 146 width: 100%; 147 padding: 0; 148 margin: 0; 149 clear: both; 150} 151 152.mean-nav .wrapper { 153 width: 100%; 154 padding: 0; 155 margin: 0; 156} 157 158/* Fix for box sizing on Foundation Framework etc. */ 159.mean-container .mean-bar, .mean-container .mean-bar * { 160 -webkit-box-sizing: content-box; 161 -moz-box-sizing: content-box; 162 box-sizing: content-box; 163} 164 165 166.mean-remove { 167 display: none !important; 168} 169

投稿2017/09/24 12:24

sutosi

総合スコア27

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

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

0

追記2です

<!DOCTYPE html> <html lang="ja"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"><!-- baneではなくname --> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css"> <link rel="stylesheet" href="https://cdn.jsdelivr.net/jquery.meanmenu/2.0.6/meanmenu.min.css"> <link rel="stylesheet" href="css/font-awesome.min.css"> <!--インストールしたfontawesomeを読み込む--> <link rel="stylesheet" href="css/styles.css"> <!--作ったCSSを読み込む--> <meta bane="viewport" content="width=device-width, initial-scale=1.0"> <!--スマホで開いたとき度の幅で描画するかの設定--> <title>RWD</title> </head> <body> <header> <div class="container"> <!-- <i class="fa fa-bars mobile-menu" aria-hidden="true"></i>--> <ul class="pc-menu"> <li>Menu</li> <li>Menu</li> <li>Menu</li> </ul> <h1 class="aburasoba">油そば池袋</h1> </div> <div class="aburasoba_main"> <div class="aburasoba_main_about"> <img src="img/wallpaper.jpg"> </div> </div> <div class="aburasoba_main2"> <div class="aburasoba_main_about2"> <img src="img/wallpaper.jpg"> </div> </div> <section class="features"><!--section1--> <h2>Features</h2> <div class="item"> <img src="img/feature.jpg"> <p class="right-side">hello. hello. hello. hello. hello. hello. hello. hello. hello. hello. hello. hello. hello. hello. hello. hello. </p> </div> <div class="item"> <img src="img/feature.jpg"> <p class="left-side">hello. hello. hello. hello. hello. hello. hello. hello. hello. hello. hello. hello. hello. hello. hello. hello. </p> </div> <div class="item"> <img src="img/feature.jpg"> <p class="right-sidet">hello. hello. hello. hello. hello. hello. hello. hello. hello. hello. hello. hello. hello. hello. hello. hello. </p> </div> </section> </header> <script src="https://code.jquery.com/jquery-3.2.1.min.js"></script> <script src="https://cdn.jsdelivr.net/jquery.meanmenu/2.0.6/jquery.meanmenu.js"></script> <script> $(function () { $("div.container").meanmenu({}); }); </script> <footer> <div class="sita"> <img src="img/footer.png"> </div> </footer> </body> </html>

投稿2017/09/24 12:24

sutosi

総合スコア27

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

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

0

追記です

/*1----------------------------------------------------------------------------------*/ @charset "utf-8"; /*common*/ body{/*初期設定、余計なmargin,paddingを0に*/ font-size: 14px; font-family: Verdana, sans-serif; margin: 0; padding: 0; color: #333; background: #F2F2F2; /*初期設定*/ } p{/*行間がゆったりする*/ line-height: 2; } .container{/*ここで90%の意味はmysiteという上の文字や写真、写真のコメントなどをかこんでいて 左右に一定の空きができる*/ width: 90%; margin: 0 auto; } /*aburasoba_main トップの背景*/ .aburasoba_main{ background-color: black; margin: 10px; } .aburasoba_main_about img{ display: block; margin-left: auto; margin-right: auto; max-width: 100%; } /*aburasoba_main トップの背景のウィンドウを小さくしたときに表示させたいやつ*/ .aburasoba_main2{ background-color: black; margin: 10px; padding-left: 50px; padding-right: 50px; } .aburasoba_main_about2 img{ display: block; margin-left: auto; margin-right: auto; max-width: 100%; } /*header-mobile-menuはアイコン右寄せ*/ .mobile-menu{ float: right; font-size: 24px; cursor: pointer; } .pc-menu{ display: none; } .pc-menu{ display: block;/*要素の表示形式をしていするっぽい、ブロック要素を表示,,*/ /*46行目にheader-pc-menuを見えない設定をして、ここで820px以上いくとここで表示させる*/ list-style: none; padding: 10px; margin: 0; /*余計なマージンパディング取る、*/ float: right;/*mysiteも入っているheader-pc-menuの中に右にする設定*/ } .pc-menu > li { display: inline-block;/*横にする設定*/ width: 60px; text-align: center; cursor: pointer; } /*sita ...imgと指定すれば画像が指定できた*/ .sita img { display: block; height: 90px; margin: 0 auto; width: 160px; } /*レスポンシブルデザイン設定①*/ /*幅の大きさが変わる設定*/ /*画面が570px以下になったとき*/ @media (max-width: 414px){ .pc-menu{/*アイコンを消す*/ display: none; } .aburasoba{/*アイコンを消す*/ display: none; } .features p{ width: 45%; } .features img{ width: 50%; } /*.pull-right*/ .right-side{ float: right; padding-left: 5%; } /*.pull-left*/ .left-side{ float: left; padding-right: 5%; } .features .item{/*float:leftやrightを使ったので*/ overflow: hidden; } .news .container{ display: flex; justify-content: space-between;/*均等に余白が空く設定*/ } .news .item{/*newsに入っている画像と文字に対して30%*/ width: 30%; } .news .item img{/*画像が30%だとちゃんと見えないので画像だけ100%に*/ width: 100%; } .aburasoba_main_about img{ display: none; } } /*画面が570px以上になったとき min-widthが〇〇以上、max-widthが〇〇までという認識*/ @media (min-width: 414px){ .container{ width: 414px; } .mobile-menu{/*アイコンを消す*/ display: none; } .aburasoba_main_about2 img{ display: none; } } /*1----------------------------------------------------------------------------------*/ section{/*共通のスタイル、上下にサイズがほしい*/ padding: 60px 0; } section h2{/*文字を中央ぞろえ、下にマージン空き*/ text-align: center; } section:nth-child(even){/*背景色の切り替え*/ background: #fff; } /*features*/ .features img{/*親要素音containerに対して100%の設定なので左右ぴったりになった*/ width: 100%; } .features .item{/*写真と文字を囲っているfeaturesの下の空き*/ margin-bottom: 60px; margin-left: 60px; margin-right: 60px; } .features .item:last-child{/*これにだけ指定という意味*/ margin-bottom: 0; } .news .item:last-child{/*これにだけ指定という意味*/ margin-bottom: 0; } /*footer*/ footer { text-align: center; padding: 10px 0; }

投稿2017/09/24 12:22

sutosi

総合スコア27

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

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

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

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

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

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

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

ただいまの回答率
85.48%

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

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

質問する

関連した質問