简体   繁体   English

我的网站在 760px 处中断。 我该如何解决?

[英]My site breaks at 760px. How can I fix it?

 window.onload = function(){ const pattern = trianglify({ width: window.innerWidth, height: window.innerHeight, cellSize: 75, xColors: 'Blues', yColors: 'match', variance: 0.75, fill: true, }) document.getElementById('background').appendChild(pattern.toCanvas()) /* Customization width: 600, height: 400, cellSize: 75, variance: 0.75, seed: null, xColors: 'random', yColors: 'match', fill: true, palette: trianglify.colorbrewer, colorSpace: 'lab', colorFunction: trianglify.colorFunctions.interpolateLinear(0.5), strokeWidth: 0, points: null } */ let ageInput = document.querySelector('#ageInput'); let heightInput = document.querySelector('#heightInput'); let weightInput = document.querySelector('#weightInput'); let extremeWeightGain = document.getElementById('extremeWeightGain') let averageWeightGain = document.getElementById('averageWeightGain') let mildWeightGain = document.getElementById('mildWeightGain') let mildWeightLoss = document.getElementById('mildWeightLoss') let averageWeightLoss = document.getElementById('averageWeightLoss') let extremeWeightLoss = document.getElementById('extremeWeightLoss') let btnAdd = document.querySelector('button'); let maintainCalories = document.getElementById('maintainCalories'); const selectElement = document.getElementById('exerciseInput') let exerciseValue = { price: 0 } selectElement.addEventListener("change", function(e) { const inputValue = e.target.value; if (inputValue == 'noExercise') { exerciseValue.price = -150; } if (inputValue == 'lightExercise') { exerciseValue.price = -50; } if (inputValue == 'moderateExercise') { exerciseValue.price = 100; } if (inputValue == 'activeExercise') { exerciseValue.price = 250; } if (inputValue == 'veryActiveExercise') { exerciseValue.price = 375; } if (inputValue == 'extraActiveExercise') { exerciseValue.price = 500; } }) btnAdd.addEventListener('click', () =>{ let zyzz = parseFloat(weightInput.value*10) + parseFloat(heightInput.value*6.25) - parseFloat(ageInput.value*5) + parseInt(genderValue.price) + parseInt(exerciseValue.price); maintainCalories.innerText = zyzz.toFixed(0); extremeWeightGain.innerText = zyzz *100 /71; averageWeightGain.innerText = zyzz *100 /81; mildWeightGain.innerText = zyzz *100 /89; mildWeightLoss.innerText = zyzz *88 /100; averageWeightLoss.innerText = zyzz *76 /100; extremeWeightLoss.innerText = zyzz *66 /100; extremeWeightGain.innerHTML = Math.round(extremeWeightGain.innerHTML *1); averageWeightGain.innerHTML = Math.round(averageWeightGain.innerHTML *1); mildWeightGain.innerHTML = Math.round(mildWeightGain.innerHTML *1); mildWeightLoss.innerHTML = Math.round(mildWeightLoss.innerHTML *1); averageWeightLoss.innerHTML = Math.round(averageWeightLoss.innerHTML *1); extremeWeightLoss.innerHTML = Math.round(extremeWeightLoss.innerHTML *1); }); var genderValue = { price: 0 } var maleValue = document.getElementById('Male'); Male.addEventListener('click',function(){ genderValue.price = 5; }) var femaleValue = document.getElementById('Female'); Female.addEventListener('click',function(){ genderValue.price = -161; }) } function showResults() { document.getElementById("input1").style.display="none"; document.getElementById("input2").style.display="none"; document.getElementById("input3").style.display="none"; document.getElementById("input4").style.display="none"; document.getElementById("input5").style.display="none"; document.getElementById("input6").style.display="none"; document.getElementById('hideButton').style.display = "none"; document.getElementById("resultsSection").style.display="block"; }
 .main-section { padding-top: 79px; padding-left: 500px; width: 903px; font-family: 'Anton', sans-serif; display: block;}.background { position: sticky; overflow: hidden;}.wholeArea { position: absolute; top: 0; right: 0;}.title { font-size: 60px; color: #132c54;}.description { font-size: 25px; color: #2569c8; line-height: 29px; margin-bottom: 8px;}.inputText { font-size: 30px; color: #132c54; background-color: white;}.inputField { font-size: 30px; color: #132c54; border-color: #132c54; border-width: 4px; border-style: solid; outline-color: #132c54; border-radius: 6px;}.noDecoration { /* No Text Decoration */ text-decoration: none; color: #132c54;}.selectInput { width: 413px; color: #132c54; outline-color: #132c54; outline-width: 0px; border-color: #132c54; border-width: 4px; border-style: solid; border-radius: 6px;}.textInput { width: 400px; display: inline; color: #132c54; outline-color: #132c54; outline-width: 0px; border-color: #132c54; border-width: 4px; border-style: solid; border-radius: 6px; padding-left: 3px;}.selectOption { font-size: 30px; color: #132c54;}.buttonStyle { font-size: 35px; color: #132c54; background-color: white; outline-color: #132c54; outline-width: 0px; border-color: #132c54; border-width: 4px; border-style: solid; border-radius: 6px;}.radioStyle { width: 20px; height: 20px; display: inline-block; vertical-align: top;}.leftColumnBox { position: absolute; margin-right: 100px; width: auto; height: auto;}.leftColumnBox2 { position: absolute; margin-top: 321px; margin-right: 100px; width: auto; height: auto;}.rightColumnBox { position: absolute; margin-right: 100px; width: auto; height: auto;}.rightColumnBox2 { position: absolute; margin-top: 321px; margin-right: 100px; width: auto; height: auto;}.leftColumn { width: auto; height: auto; margin-top: 81px; margin-left: 100px; margin-right: 100px; float: left; position: fixed; display: inline; top: 0px; left: 0px;}.rightColumn { width: auto; height: auto; margin-top: 81px; margin-left: 100px; margin-right: 400px; float: left; position: fixed; display: inline; top: 0px; right: 0px;}.advertImage { border: 10px white solid; border-radius: 6px; width: 300px; height: auto;}.resultsSection { display: none;}.radioArea { height: 45px; width: 700px; display: block;}.inputArea { height: 50px; width: 700px; display: block;}.labelText { width: 150px; display: inline-block;}.resultsText { line-height: 40px; padding: 0px; border: 0px; margin: 0px;}.hideInput { display: block;}.mainBorder { border: 20px solid white; border-radius: 12px; background-color: white;}.titleBorder { border: 20px solid white; border-bottom: none; border-top-left-radius: 12px; border-top-right-radius: 12px; background-color: white;}.descBorder { border: 20px solid white; border-bottom-left-radius: 12px; border-bottom-right-radius: 12px; background-color: white;} a:link { text-decoration: none; } a:visited { text-decoration: none; } a:hover { text-decoration: none; } a:active { text-decoration: none; } @media screen and (max-width: 780px) {.main-section { padding-top: 64px; padding-left: 10%; padding-right: 0px; width: 80%; }.leftColumn { width: 240px; height: auto; margin-top: 41px; margin-left: 85px; margin-right: 30px; float: left; position: static; display: block; width: 30%; }.rightColumn { width: 240px; height: auto; margin-top: 41px; margin-left: 70px; margin-right: 0px; float: left; position: fixed; position: static; display: block; width: 30%; }.advertImage { border: 10px white solid; border-radius: 6px; width: 240px; height: auto; }.leftColumnBox2 { display: none; }.rightColumnBox2 { display: none; }.textInput { width: 350px; }.selectInput { width: 363px; }.title { font-size: 40px; }.description { font-size: 18px; }.labelText { width: 150px; }} @media screen and (max-width: 760px) {.main-section { padding-top: 64px; padding-left: 11%; padding-right: 0px; width: 80%; }.leftColumn { width: 240px; height: auto; margin-top: 41px; margin-left: 88px; margin-right: 30px; float: left; position: static; display: block; width: 30%; }.rightColumn { width: 240px; height: auto; margin-top: 41px; margin-left: 70px; margin-right: 0px; float: left; position: fixed; position: static; display: block; width: 30%; }.advertImage { border: 10px white solid; border-radius: 6px; width: 240px; height: auto; }.leftColumnBox2 { display: none; }.rightColumnBox2 { display: none; }.textInput { width: 350px; }.selectInput { width: 363px; }.title { font-size: 40px; }.description { font-size: 18px; }.labelText { width: 150px; }}.banner { /* Banner Styles */ width: 100%; color: black; font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif; font-size: 24px; float: left; text-decoration: none; cursor: pointer;} html, body { max-width: 100%; overflow-x: hidden;}.noselect { /* No Highlighting */ -webkit-touch-callout: none; /* iOS Safari */ -webkit-user-select: none; /* Safari */ -khtml-user-select: none; /* Konqueror HTML */ -moz-user-select: none; /* Old versions of Firefox */ -ms-user-select: none; /* Inte.net Explorer/Edge */ user-select: none; /* Non-prefixed version, currently supported by Chrome, Edge, Opera and Firefox */}.banner-head-1 { /* Home Header */ float: left; overflow-wrap: normal; margin-left: 200px; margin-right: 200px; text-decoration: none; color: black; display:block;}.banner-head-2 { /* Food Header */ float: left; overflow-wrap: normal; margin-left: 55px; text-decoration: none; color: black; display:block;}.banner-head-3 { /* Exercise Header */ float: left; overflow-wrap: normal; margin-left: 55px; text-decoration: none; color: black; display:block;}.banner-head-4 { /* Calculators Header */ float: left; overflow-wrap: normal; margin-left: 55px; text-decoration: none; color: black; display:block;}.banner-head-5 { /* Calculators Header */ float: left; overflow-wrap: normal; margin-left: 55px; text-decoration: none; color: black; display:block;}.dropdown { /* Dropdown Content */ cursor: pointer; color: black; font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif; font-size: 24px; display:none; position:absolute; width: 100%; float: left; text-decoration: none; padding-right: 80px; margin: 0px; border: 0px;}.noDecoration { /* No Text Decoration */ text-decoration: none; color: black;}.dropdown-content { display: none; padding-left: 20px;}.banner-logo { height: 40px; border: 10px solid white; border-radius: 12px; margin-top: 5px;}.banner-logo-responsive { margin-left: 150px; height: 43px; margin-top: 5px; margin-bottom: 5px; border: 10px solid white; border-radius: 12px; margin-left: 350px;}.mobile-logo { height: 80px; padding: none; border: 10px white solid; border-radius: 8px;} @media screen and (max-width: 780px) {.banner-head-1 { /* Home Header */ margin-left: 6px; margin-right: 10px; }.banner-head-2 { /* Food Header */ margin-left: 15px; }.banner-head-3 { /* Exercise Header */ margin-left: 15px; }.banner-head-4 { /* Calculators Header */ margin-left: 15px; }.banner-head-5 { /* Calculators Header */ margin-left: 15px; }.banner-logo { height: 22px; }} @media screen and (max-width: 760px) {.banner-head-1 { /* Home Header */ margin-left: 10px; margin-right: 10px; }.banner-head-2 { /* Food Header */ margin-left: 15px; }.banner-head-3 { /* Exercise Header */ margin-left: 15px; }.banner-head-4 { /* Calculators Header */ margin-left: 15px; }.banner-head-5 { /* Calculators Header */ margin-left: 15px; }.banner-logo { height: 21px; }}
 <div class="mainBorder calculatorSection" id="inputSection"> <:-- Calculator --> <div class="radioArea" style="padding-bottom; 5px." id="input1"> <label class="inputText noDecoration labelText">Units</label> <a href="./calorie-calculator.html"> <input type="radio" class="inputField radioStyle" onclick="window.location='./calorie-calculator.html'"> <label class="inputText noDecoration">Metric</label> </a> <a href="./calorie-calculator-imperial.html"> <input type="radio" class="inputField radioStyle" onclick="window.location='./calorie-calculator-imperial;html'"> <label class="inputText noDecoration">Imperial</label><br> </a> </div> <div class="radioArea" id="input2"> <label for="gender" class="inputText labelText">Gender</label> <input type="radio" id="Male" name="gender" value="5" class="inputField radioStyle"> <label for="Male" class="inputText">Male</label> <input type="radio" id="Female" name="gender" value="-165" class="inputField radioStyle"> <label for="Female" class="inputText">Female</label><br> </div> <div class="inputArea" id="input3"> <label for="ageInput" class="inputText labelText">Age</label> <input type="number" id="ageInput" class="inputField textInput" placeholder="12-80"><br> </div> <div class="inputArea" id="input4"> <label for="heightInput" class="inputText labelText">Height</label> <input type="number" id="heightInput" class="inputField textInput" placeholder="100cm - 200cm"><br> </div> <div class="inputArea" id="input5"> <label for="weightInput"class="inputText labelText">Weight</label> <input type="number" id="weightInput" class="inputField textInput" placeholder="30kg - 120kg"><br> </div> <div class="inputArea" id="input6"> <label for="exerciseInput"class="inputText labelText">Exercise</label> <select id="exerciseInput" class="inputText selectInput"> <option class="inputText selectOption">Exercise</option> <option value="noExercise" id="noExercise" class="inputText selectOption">Inactive</option> <option value="lightExercise" id="lightExercise" class="inputText selectOption">Light Activity</option> <option value="moderateExercise" id="moderateExercise" class="inputText selectOption">Moderate Activity</option> <option value="activeExercise" id="activeExercise" class="inputText selectOption">Active</option> <option value="veryActiveExercise" id="veryActiveExercise" class="inputText selectOption">Very Active</option> <option value="extraActiveExercise" id="extraActiveExercise" class="inputText selectOption">Extra Active</option> </select><br> </div> <button class="buttonStyle" onclick="showResults()." id="hideButton">ADD</button> <span class="resultsSection" id="resultsSection"> <div class="inputText resultsText">Extreme Weight Gain(1kg/week) - <span id="extremeWeightGain" class="inputText"></span></div> <div class="inputText resultsText">Weight Gain(0.5kg/week) - <span id="averageWeightGain" class="inputText"></span></div> <div class="inputText resultsText">Mild Weight Gain(0.25kg/week) - <span id="mildWeightGain" class="inputText"></span></div> <div class="inputText resultsText">Maintain Calories - <span id="maintainCalories" class="inputText"></span></div> <div class="inputText resultsText">Mild Weight Loss(0.25kg/week) - <span id="mildWeightLoss" class="inputText"></span></div> <div class="inputText resultsText">Weight Loss(0.5kg/week) - <span id="averageWeightLoss" class="inputText"></span></div> <div class="inputText resultsText">Extreme Weight Loss(1kg/week) - <span id="extremeWeightLoss" class="inputText"></span></div> </span> </div>

Hi there,你好呀,

I am trying to make my site responsive but it stops working at 760px.我试图让我的网站响应,但它在 760 像素时停止工作。 When it his 760px everything else gets moved and out of place.当它是他的 760px 时,其他所有内容都会移动并错位。 The problem happens when I click on a button to hide the input section and display the answers.当我单击按钮以隐藏输入部分并显示答案时,就会出现问题。 Nothing is displaced on the button press for 760px+. 760 像素以上的按钮按下时没有任何位移。 The code is very similar at each code break and I can't find the issue.每次代码中断时的代码都非常相似,我找不到问题所在。

Here is what it looks like before the button press: img-1这是按下按钮之前的样子: img-1

Here is what it looks like after the button press img-2这是按下按钮后的样子img-2

Check out these:看看这些:

object-fit:cover;对象拟合:覆盖;

@media screen and (min-width: 000px) and (max-width: 000px) @media screen and (min-width: 000px) and (max-width: 000px)

I guess, you have radioArea width set to 700px, maybe that's why?我猜,您将radioArea宽度设置为 700px,也许这就是为什么? Width of your class are fixed, you have to change it according to screen width, if you want to make a responsive design For example you can use width in percents, not in fixed pixels, but add max-width property, as you do not want to have it more than 700px您的 class 的宽度是固定的,如果您想进行响应式设计,您必须根据屏幕宽度更改它例如,您可以使用百分比宽度,而不是固定像素,但添加max-width属性,因为您没有想要超过 700px

At (max-width: 760px) you set the overflow-x: hidden , it will break the EventListener.在 (max-width: 760px) 你设置了overflow-x: hidden ,它会破坏 EventListener。

The solution is to set overflow-x: auto解决办法是设置overflow-x:auto

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我的网站不断伸展,我该如何解决? - My site keeps stretching itself, how can I fix it? 我如何修复中断显示我的网站的 MQTT 问题(使用 React 和 raspberryPi)? - How can I fix MQTT problems (using react and raspberryPi) which breaks displaying my website? 我的 Function 在爆发前只循环一次。 我怎样才能解决这个问题? Vuejs - My Function is only looping once before it breaks out. How can i fix this? Vuejs 我的“ div”从顶部移到底部(即,距顶部200像素的高度)并固定在顶部(开始位置)。 但我想解决问题,该怎么办? - My “div” is moving from top to bottom (i.e 200px height from top) and fix on a top(starting postion). but I want to fix on a bottom.How can I do it? 我应该担心我的网站使IE9崩溃吗? - Should I be worried that my site crashes IE9 and how to fix? 为什么仅在调试模式下运行代码时才会出现期望值,而在不调试时却会破坏期望值,我该如何解决? - Why does expected values only occur when I run my code in debug mode, but breaks when I aren't debugging, and how can I fix this? 如何在网站上启用压缩? - How can I enable compression on my site? 使用Google JSAPI会破坏我的infieldlabel javascript,为什么以及如何解决它? - Using Google JSAPI breaks my infieldlabel javascript, why and how do I fix it? 如何在 JavaScript 中将 px 转换为 vw? - How can I convert px to vw in JavaScript? 如何制作以 px 为宽度的 ProgressBar? - How can I make a ProgressBar with px as width?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM