简体   繁体   English

调整页面大小后,div下降

[英]Div going down after when page resized

css: CSS:

  .desc{
        text-align: center;
        color:#60A8D5;
        padding-top: 17px;
        font-size: 14px; font-family: sans-serif;
        font-weight: normal;
        width: 400px;
        margin: 20px;
        display:inline-block;
        vertical-align: top;

        position: relative;
    }
    .twitter{
    background-image: url(http://guifff.com/wp-content/uploads/45_dribbble-twitter.gif);
        background-position: center; 
        margin-top: 210px;
        margin-left: 15%;
        margin-right: 7%;
        width: 78%;
        height: 270px;
        padding-top: 0px;
        text-align: right;
        position: relative;

    }

    .insegnanti{ 

        display:inline-block;
        width:auto;
        text-align: center;
        margin: 20px;
        padding: 5px;
        height: 200px;
        vertical-align: top;
        }

html part: html部分:

 <div class='insegnanti' id='i"+instructor[i].id+"'><img src='"+instructor[i].image+"' style='max-width:100%;height:auto'>
         <div class='desc'><b><p style='font-size:20px'>"+instructor[i].name+" "+instructor[i].surname+"</b></p><br><br>"+instructor[i].description+"
         </div>
  </div>

   <div class='twitter'><a class='twitter-timeline' href='https://twitter.com/"+instructor[i].twitter+"' data-widget-id='"+instructor[i].twitter_id+"'>Tweet di @"+instructor[i].twitter+"</a></div>

When i resize the page, the desc part going under twitter div. 当我调整页面大小时,desc部分将进入twitter div。 Without resize i see the img on the left and the desc on the right, and twitter at the bottom. 没有调整大小,我在左边看到img,在右边看到desc,在底部看到twitter。 When i resize i want twitter div goes down after the resize. 当我调整大小时,我希望Twitter div在调整大小后下降。 How can i do it? 我该怎么做?

Remove margin-top: 210px; 删除页margin-top: 210px; from .twitter , then remove height: 200px; .twitter ,然后删除height: 200px; from .insegnanti . 来自.insegnanti And this seems to fix it. 这似乎可以解决它。

Not sure exactly where you want to position your div. 不确定要在哪个位置放置div。 use the below CSS as a guide and modify it to suit your needs. 使用以下CSS作为指导,并对其进行修改以适合您的需求。 Add margin-top and margin-bottom if needed. 如果需要,请在顶部添加边距,在底部添加边距。

#desc {
  position: absolute;
  margin-left: 25px;
  margin-right: -25px;
}

Hope this helps. 希望这可以帮助。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM