首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
社区首页 >问答首页 >基于w3.css模板的响应式布局覆盖内容,垂直滚动,并且内容不想居中

基于w3.css模板的响应式布局覆盖内容,垂直滚动,并且内容不想居中
EN

Stack Overflow用户
提问于 2017-09-06 12:46:10
回答 1查看 637关注 0票数 1

我在这上面花了几天时间,用另一个模板重建了页面,尝试了网上的建议,这导致我进一步打破了布局。我更像是一名设计师,而不是一名程序员,我找不到我还能尝试什么。请帮帮我!我面临的问题:最糟糕的:div彼此重叠。然后中间的旋转木马过去是居中的,现在不再居中了,它也不关心边缘:自动。然后垂直卷轴就出现了。所有这些问题都与我尝试解决重叠div的响应式布局有关。好心情/屏幕大小的布局看起来像这样:好的大屏幕布局。

最差的屏幕尺寸返回如下:所有错误的布局

剥离我页面的代码:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
<html>
<title></title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
<link rel="stylesheet" href="css/magnificpopup.css">
<link href="stylesheet.css" rel=stylesheet type="text/css">
<style>
.w3-half img{margin-bottom:-6px;margin-top:16px;opacity:0.8;cursor:pointer}
.w3-half img:hover{opacity:1}
</style>
<body>
<!-- Sidebar/menu -->
<nav class="w3-sidebar w3-white w3-collapse w3-top w3-large w3-padding-large" style="z-index:3;width:350px;font-weight:bold;" id="mySidebar"><br>
  <a href="javascript:void(0)" onclick="w3_close()" class="w3-button w3-hide-large w3-display-topleft" style="width:100%;font-size:22px">Close Menu</a>
  <div class="w3-container">
    <h3 class="w3-padding-64"><br></h3>
  </div>
  <div class="w3-bar-block">
        <nav id="menu" class="leftDivPosition">
              <header>
              <a href="index.php">
                  <div class="logotype"><img src="images/logo.gif" alt="logo"></div>
              </a>
              </header>
             <ul>
              <li><div class="menuText">Photoshop</div></li>
              <li><div class="menuText">Graphic design</div></li>
              <li><div class="menuText">Product design</div><li>
              <div class="menuText">3D</div></li> 
              <li><div class="menuText">About me</div></li>
              <li><div class="menuText">Contacts</div></li>
            </ul>
        </nav>
   </div>
</div>
</nav>

<!-- Top menu on small screens -->
<header class="w3-container w3-top w3-hide-large w3-white w3-xlarge w3-padding">
  <a href="javascript:void(0)" class="w3-button w3-grey w3-margin-right" onclick="w3_open()"></a>
 </header>
<!-- Overlay effect when opening sidebar on small screens -->
<div class="w3-overlay w3-hide-large" onclick="w3_close()" style="cursor:pointer" title="close side menu" id="myOverlay"></div>
<!-- !PAGE CONTENT! -->
<div class="w3-main w3-row" style="margin-left:340px;margin-right:15px">
<!-- Main -->
<div class="w3-col m9 19"> 
    <div class="w3-container" id="designers" style="margin-top:75px">
        <div style="margin:auto;">
         <ul style="list-style-type:none;" id="carousel">
                <li><a class="magnificpopup" href="images/cookbook_cover_th.jpg">
                <img src="images/cookbook_cover_thsz.jpg" name="CarouselImg1"/></a></li>
                <li></li>
          </ul>
 </div> </div> 
</div>

<!--right sidebar -->
<div class="w3-col m3 13"> 
    <div class="w3-row" id="designers" style="margin-top:100px; overflow:visible;">
        <div>
                <div class="w3-col m7 w3-margin-bottom w3-padding">
                        <div class="w3-container w3-padding-large">
                             <ul>
                            <li><a href="http://facebook.com/"><i></i></a></li>
                            <li><a href="http://linkedin.com/"><i></i></a></li>
                            </ul>
                        </div>
                </div>
                <!--vertical copyright for big screens -->
                <div class="w3-container w3-col m5 w3-padding-large w3-hide-small">
                    <p style="-webkit-transform:rotate(90deg) !important;-moz-transform:rotate(90deg) !important;-o-transform: rotate(90deg !important);-ms-transform:rotate(90deg !important);transform: rotate(90deg !important);white-space:nowrap !important;display:block !important;width:20px;">© 20142017 Vidaldigital.com. All Rights Reserved.</p>
                </div>
                <!--horisontal copyright for small screens -->
                 <div class="w3-container w3-col m4 w3-padding-large w3-hide-medium w3-hide-large">                      <p>© 20142017 Vidaldigital.com</p>
                </div>
        </div>
  </div>
</div>
<!-- End page content -->
</div>
</body>
</html>

我使用的主要是css从w3.css文件,并建立了他们的室内设计模板的设计。我自己的CSS是最小的,与响应式布局无关,我假设对carousel的脚本调整也是如此,但当然,如果我能得到一些帮助,我可以分享一切。

我甚至必须补充说,当插入jQuery旋转木马时,它仍然与右侧边栏和其他内容重叠,否则它将完全不受影响。如果问题可能出在旋转木马中,我甚至添加了我所做的修改:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
<script type="text/javascript">
  $(document).ready(function() {
    $("#carousel").waterwheelCarousel({
       startingItem:               1,   // item to place in the center of the carousel. Set to 0 for auto
    separation:                 255, // distance between items in carousel
    separationMultiplier:       0.6, // multipled by separation distance to increase/decrease distance for each additional item
    horizonOffset:              0,   // offset each item from the "horizon" by this amount (causes arching)
    horizonOffsetMultiplier:    1,   // multipled by horizon offset to increase/decrease offset for each additional item
    sizeMultiplier:             0.6, // determines how drastically the size of each item changes
    opacityMultiplier:          0.7, // determines how drastically the opacity of each item changes
    horizon:                    0,   // how "far in" the horizontal/vertical horizon should be set from the container wall. 0 for auto
    flankingItems:              2,   // the number of items visible on either side of the center                  

    // animation
    speed:                      3000,      // speed in milliseconds it will take to rotate from one to the next
    animationEasing:            'swing', // the easing effect to use when animating
    quickerForFurther:          true,     // set to true to make animations faster when clicking an item that is far away from the center
    edgeFadeEnabled:            true,    // when true, items fade off into nothingness when reaching the edge. false to have them move behind the center image

    // misc
    linkHandling:               2,                 // Determines behavior of links that are placed around the images. 1 to disable all (if you want to use the callback functions to do something special with the links; or used for facebook), 2 to disable all but center (to link images out).You can wrap all of the images in links if you'd like. Most people will probably want to add links around each image, but only activate the links when the center item is clicked. This is the default use case. However, you can turn all of the links off if you prefer using the callback functions to handle the links. 
    autoPlay:                   300,                 // indicate the speed in milliseconds to wait before autorotating. 0 to turn off. Positive value for a left to right movement, negative for a right to left. 
    orientation:                'vertical',      // indicate if the carousel should be 'horizontal' or 'vertical'
    activeClassName:            'carousel-center', // the name of the class given to the current item in the center
    keyboardNav:                true,             // set to true to move the carousel with the arrow keys
    keyboardNavOverride:        false,              // set to true to override the normal functionality of the arrow keys (prevents scrolling)
    imageNav:                   true,              // clicking a non-center image will rotate that image to the center.False to disable that functionality, which is commonly paired with navigational buttons instead.

    // preloader
    preloadImages:              true,  // disable/enable the image preloader.The carousel will attempt to preload all images before initializing. This is known to have some issues in certain browsers. The main reason for the preloader is too be able to determine the dimensions for each image before running calculations. If you run into issues, disable this and use the forced proportions below (or set your image dimensions using CSS). 
    forcedImageWidth:           0,     // Set a global width that should be applied to all images in the carousel. specify width of all images; otherwise the carousel tries to calculate it
    forcedImageHeight:          0,     // Set a global height that should be applied to all images in the carousel. specify height of all images; otherwise the carousel tries to calculate it

    // callback functions
    movingToCenter:             $.noop, // fired when an item is about to move to the center position
    movedToCenter:              $.noop, // fired when an item has finished moving to the center
    clickedCenter:              $.noop, // fired when the center item has been clicked
    movingFromCenter:           $.noop, // fired when an item is about to leave the center position
    movedFromCenter:            $.noop 

      // include options like this:
      // (use quotes only for string values, and no trailing comma after last option)
      // option: value,
      // option: value
    });
});
</script>
EN

回答 1

Stack Overflow用户

发布于 2017-09-06 12:55:18

至于你的居中问题,我想是在html的这一部分:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
<div class="w3-col m9 19"> 
   <div class="w3-container" id="designers" style="margin-top:75px">
      <div style="margin:auto;">
         <ul style="list-style-type:none;" id="carousel">
            <li>
               <a class="magnificpopup" href="images/cookbook_cover_th.jpg">
                  <img src="images/cookbook_cover_thsz.jpg" name="CarouselImg1"/>
               </a>
            </li>
            <li></li>
         </ul>
      </div>
   </div> 
</div>

我认为您正在尝试将第三个div居中放置在第一个div中,该第一个div被设置为预设的列宽度。但是,在它们之间的第二个div正在成为障碍。第三个div居中,但它在第二个div内居中。但是第二个div只需要和第三个div一样宽(以容纳它)。第二个div没有在第一个div中居中,因为您没有告诉它是居中的。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/46075651

复制
相关文章
内容垂直居中
测试内容测试内容测试内容测试内容测试内容测试内容测试内容测试内容测试内容测试内容测试内容测试内容测试内容测试内容测试内容测试内容测试内容
GhostZhang
2022/08/21
9990
flex布局垂直居中并换行展示内容
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/142011.html原文链接:https://javaforall.cn
全栈程序员站长
2022/08/25
9690
flex布局垂直居中并换行展示内容
flex布局垂直居中
外框高都为400px,边框为2px;圆的宽高为100px;中圆是水平居中;下圆是水平居中以及相对于中圆垂直居中(下圆到中圆的距离和下圆到下边框的距离相等)。效果如图:
全栈程序员站长
2022/07/01
5710
flex布局垂直居中
[CSS] CSS display:flex实现内容水平垂直居中展示
首先父级元素必须有高度,没有高度就无法垂直居中,如果想全屏垂直居中,可以设置高度为100vh
唯一Chat
2022/07/24
9030
[CSS] CSS display:flex实现内容水平垂直居中展示
CSS实现垂直居中布局
首先将<html>与<body>的高度设置为100%(为演示父元素不定宽高的效果),并清除<body>的默认样式
WindRunnerMax
2020/08/27
1.8K0
flex布局实现垂直居中
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/132357.html原文链接:https://javaforall.cn
全栈程序员站长
2022/08/12
1.3K0
flex布局实现垂直居中
flex布局以及实现垂直居中
给父盒子添加flex属性,来控制盒子的位置和排列方式(当我们给父元素设置为flex布局以后,子元素的float、clear和vertical-align属性将失效) flex:布局又叫伸缩布局,弹性布局,伸缩盒布局,flex布局 flex常见的父项常见属性 flex-direction:设置主轴的方向 justify-content:设置主轴上的子元素排列方式 flex-wrap:设置子元素是否换行 align-content:设置侧轴上的子元素的排列方式(多行) align-items:设置侧轴上的子元素排列方式(单行) flex-flow:复合属性,相当于同时设置了 flex-direction 和 flex-wrap flex常见的子项属性 flex子项目占的分数 aglin-self控制子项目自己在侧轴的排列方式 order属性定义子项的排列顺序(前后顺序)
全栈程序员站长
2022/09/06
7720
flex垂直居中,水平居中和其他布局方式
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/132066.html原文链接:https://javaforall.cn
全栈程序员站长
2022/06/30
5230
flex布局实现div的水平垂直居中
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/143096.html原文链接:https://javaforall.cn
全栈程序员站长
2022/08/31
1.9K0
flex布局实现div的水平垂直居中
css flex布局实现文字垂直居中
在没使用flex之前,垂直居中最常用的方法就是将容器的line-height设置为和容器一样的高度,但这种方法很生硬,每次需要更改容器高度的时候都需要考虑line-height,使用以下这种方法可以实现自适应的垂直居中!
全栈程序员站长
2022/09/06
1.9K0
css flex布局实现文字垂直居中
CSS布局之垂直居中一
CSS中的水平居中是非常容易实现的,比如对于行内元素,将它的父级元素设置text-align为center既可。 对于块级元素,设置它的margin:auto即可 但是,对于设置垂直居中来说,操作就没那么简单了。 不同情况要不同应对。一般我们可以有三种思路的解决方案。 今天我们先来讨论利用绝对定位解决垂直居中的思路。 如上,在能已知元素宽高的情况下,利用绝对定位将左上角定位到父级元素正中心,注意父级元素应设置“定位”,不然按照绝对定位的性质,元素会依次找寻其他已“定位”的祖先元素定位(实在没
企鹅号小编
2018/01/26
7050
html flex上下居中,css3 flex实现div内容水平垂直居中的几种方法
※ flex-direction:column-reverse (与column 相反)
全栈程序员站长
2022/08/23
3.2K0
html flex上下居中,css3 flex实现div内容水平垂直居中的几种方法
2.布局解决方案- 垂直居中<2>
垂直布局 写出两个盒子并满足以下条件条件: 1.里面的高度盒子不固定 2.外面盒子的高度不固定
河湾欢儿
2018/09/06
3050
JS动态添加内容时让滚动条跟随内容的增加滚动
这两天研究GPT,然后在写对话时,因为对话是js动态添加的,然后随着内容的增多,要想让滚动条跟随内容的增多往下滚动,所以需要添加一个滚动条监听,并且随着内容增多将滚动条自动往下滚动。
岳泽以
2023/05/19
3K0
css布局 - 垂直居中布局的一百种实现方式(更新中...)
1. line-height行高简单粗暴实现法:line-height:Npx(N = 与元素高度相同的值)
xing.org1^
2018/09/20
3.5K0
css布局 - 垂直居中布局的一百种实现方式(更新中...)
html中table居中和表格内容居中的问题
有时候在Div中加上 <div style=”text-align:center”></div>里面的Table是不会居中的我们可以在Table中加上 margin:auto比如:
全栈程序员站长
2022/11/04
5.6K0
响应式布局
原理:在不同屏幕下,通过媒体查询来改变布局容器的大小,再改变里面子元素的排列方式和大小,从而实现在不同大小的屏幕下,看到不同的页面布局和样式。
赤蓝紫
2023/01/01
2.9K0
响应式布局
响应式布局rem布局
第一步:从UI设计师拿到设计稿(psd) 640*1136 第二部:在样式中给HTML一个fontSize值,我们一般都给一个比较好算的值,比如:10px 100px... 在这里我们之所有用100px,主要是浏览器最小的字体大小都是12px,用10px比例会存在偏差
河湾欢儿
2018/09/06
1.9K0
css实现布局垂直居中以及@media的用法总结
aspect-ratio:检测浏览器可视宽度和高度的比例。(例如:aspect-ratio:16/9)
Gujiu
2022/03/29
4880
css实现布局垂直居中以及@media的用法总结
div垂直居中的几种方式_div垂直水平居中
利用CSS进行元素的水平居中,比较简单,行级元素设置其父元素的text-align center,块级元素设置其本身的left 和 right margins为auto即可。本文收集了六种利用css进行元素的垂直居中的方法,每一种适用于不同的情况,在实际的使用过程中选择某一种方法即可。
全栈程序员站长
2022/08/03
4.2K0
div垂直居中的几种方式_div垂直水平居中

相似问题

响应式布局的垂直居中

10

垂直居中,2列响应式内容溢出

10

响应式布局中的居中分区内容

34

居中块中左对齐的内容(响应式布局)

23

垂直居中内容

31
添加站长 进交流群

领取专属 10元无门槛券

AI混元助手 在线答疑

扫码加入开发者社群
关注 腾讯云开发者公众号

洞察 腾讯核心技术

剖析业界实践案例

扫码关注腾讯云开发者公众号
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档
查看详情【社区公告】 技术创作特训营有奖征文