javascript - 响应式 CSS 检查

标签 javascript css mobile web

试图让内容出现在这个 css 中以在网站上得到很好的响应,但是内容在左到右形成一个滚动条,这在移动设备上很难管理。唯一 react 良好的部分是移动设备的自定义导航,#wrapper、内容和页脚都 react 不太好。

/**********************************
GENERAL
***********************************/
* {
  margin: 0;
}

html{
    height: 100%;
}
body {
  min-height: 100%;
}


img{
  max-width: 100%;
  /*width: 250px;
  margin-right: 15px;
  float: left;
  margin-bottom: 20px;
  padding:1px;
  border:1px solid #021a40;*/
  }

#wrapper{
  max-width: 100%;
  max-height: 100%;
  border-style: dashed;
  margin: 0 auto;
  padding: 0 5%;
  height: 1000px;
  width: 960px;
  flex: 1;
background: rgba(255,255,255,1);
}

li{
  text-decoration: none;
  list-style-type: none;
}

h1{
  text-align: center;
}
/**********************************
HEADING
***********************************/



/**********************************
NAVIGATION
***********************************/
ul.topnav {
  list-style-type: none;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background-color: #333;
}

ul.topnav li {float: left;}

ul.topnav li a {
  display: inline-block;
  color: #f2f2f2;
  text-align: center;
  padding: 14px 16px;
  text-decoration: none;
  transition: 0.3s;
  font-size: 17px;
}

ul.topnav li a:hover {background-color: #555;}

ul.topnav li.icon {display: none;}

@media screen and (max-width:680px) {
  ul.topnav li:not(:first-child) {display: none;}
  ul.topnav li.icon {
    float: right;
    display: inline-block;
  }
}

@media screen and (max-width:680px) {
  ul.topnav.responsive {position: relative;}
  ul.topnav.responsive li.icon {
    position: absolute;
    right: 0;
    top: 0;
  }
  ul.topnav.responsive li {
    float: none;
    display: inline;
  }
  ul.topnav.responsive li a {
    display: block;
    text-align: left;
  }
}


/**********************************
FOOTER
***********************************/

.footer{
  font-size: 0.75em;
  text-align: center;
  clear: both;
  padding-top: 50px;
  color: #ccc;
}



/**********************************
PAGE: HOME
***********************************/

#ownerimg{
  width: 250px;
  margin-right: 15px;
  float: left;
  margin-bottom: 20px;
  padding:1px;
  border:1px solid #021a40;
}


/**********************************
PAGE: ADOPTION
***********************************/
.adoptionimages{
  display: block;
  width: 300px;
  margin-right: 15px;
  float: left;
  margin-bottom: 20px;
  padding:1px;
  border:1px solid #021a40;

}

.adoptionimages2{
  max-width: 100%;
  display: block;
  width: 300px;
  margin-left: 15px;
  float: right;
  margin-bottom: 20px;
  padding:1px;
  border:1px solid #021a40;
}

/**********************************
PAGE: CONTACT
***********************************/
label {
    clear: left;
    color: black;
    font-size: 16px;
    margin: 22px 32px 6px 0;
    text-align: right;
    text-shadow: 0 1px 0 #F2F2F2;
    text-transform: capitalize;
    width: 94px;
}

form li {
    list-style-type:none;}

form {
    background: none repeat scroll 0 0 silver;
    border: 2px solid black;
    border-radius: 40px 40px 40px 40px;
    list-style: none outside none;
    margin: 60px auto;
    padding: 60px 30px;
    width: 430px;
}



input {
    background: -moz-linear-gradient(center top , gold 0%, white 20%) repeat scroll 0 0 transparent;
    border-radius: 51px 5px 90px 5px;
    color: black;
    font-family: sans-serif;
    font-size: 16px;
    height: 30px;
    margin: 4px 0 21px;
    padding: 3px;
    text-shadow: 0 -1px 0 #334F71;
    text-transform: capitalize;
    width: 256px;}

textarea {
    background: -moz-linear-gradient(center top , gold 0%, white 20%) repeat scroll 0 0 transparent;
    border-radius: 51px 5px 90px 5px;
    color: black;
    font-family: sans-serif;
    font-size: 16px;
    height: 170px;
    margin: 0 0 21px;
    padding: 12px 20px 0;
    text-shadow: 0 -1px 0 #334F71;
    text-transform: capitalize;
    width: 256px;

textarea::-webkit-input-placeholder  {
        color: #a1b2c3; text-shadow: 0px -1px 0px #38506b;
        border-radius:30px;
}


textarea:-moz-placeholder {
        color: #a1b2c3; text-shadow: 0px -1px 0px #38506b;
}


input[type=submit] {
    width: 185px; height: 52px; float: right; padding: 10px 15px; margin: 0 15px 0 0;
    -moz-box-shadow: 0px 0px 5px #999;-webkit-box-shadow: 0px 0px 5px #999;
    border: 1px solid #556f8c;
    background: -moz-linear-gradient(top, #718DA9 0%, #415D79 100%);
    background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#718DA9), color-stop(100%,#415D79));
}



/**********************************
COLORS
***********************************/

最佳答案

在您的页面中出现滚动条 的原因是文本与您的包装器重叠。如果你想让你的页面响应,也不要声明固定宽度。检查这个 fiddle 。 https://jsfiddle.net/xnbnz3zd/2/

#wrapper p{
  word-break:break-word;
}

#wrapper{
  max-width: 100%;
  max-height: 100%;
  border-style: dashed;
  margin: 0 auto;
  padding: 0 5%;
  height: 1000px;
  flex: 1;
background: rgba(255,255,255,1);
}

关于javascript - 响应式 CSS 检查,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40392460/

相关文章:

javascript - 如何扩展 MarionetteJS 模块以减少代码重复

javascript - JS - 如果 var 为空,设置值速记

javascript - 将 nextSibling 替换为其他字符串

html - 如何让所有图像都显示在我的 slider 上,同时用自己的 div 标签区分每个图像?

jquery - 在单行中滑动 div

css - angularjs 评估范围内样式 ie9 不工作

javascript - 从 json 数据中删除特定或选定的属性。我不想仅删除类别为 :null 的所有键值对

android - "adjustResize"安卓

cordova - 混合移动应用程序是否支持推送通知?

c# - 我可以在其上安装 IDE(集成开发环境)如 Visual Studio、Net-beans 的移动设备或 PDA