html - 调整大小时如何在不移动的情况下 float 它们?

标签 html css

我希望我的网站对所有分辨率都友好,这样一切都居中,当我缩小窗口时,它都向左移动并停止。但是,当我缩小窗口时,我的新闻提要低于民意调查。

这是CSS代码:

#poll {
float: left;
margin: 0px 20px;
}

#newsfeed {
float: right;
margin: 0px 20px;
}

 <div id="poll">
 <form method="post" action="http://poll.pollcode.com/t78ar8"><table border=0 width="244" bgcolor="EEEEEE" cellspacing="2" cellpadding="0"><tr><td colspan="2" height="10"><font face="Tahoma" size="2" color="000000"><b>What game site do you visit most?</b></font></td></tr><tr><td width="5"><input type="radio" name="answer" value="1" id="t78ar8answer1"></td><td>&nbsp;<font face="Tahoma" size="2" color="000000"><label for="t78ar8answer1">Ign</label></font></td></tr><tr><td width="5"><input type="radio" name="answer" value="2" id="t78ar8answer2"></td><td>&nbsp;<font face="Tahoma" size="2" color="000000"><label for="t78ar8answer2">GameSpot</label></font></td></tr><tr><td width="5"><input type="radio" name="answer" value="3" id="t78ar8answer3"></td><td>&nbsp;<font face="Tahoma" size="2" color="000000"><label for="t78ar8answer3">GameFAQs</label></font></td></tr><tr><td width="5"><input type="radio" name="answer" value="4" id="t78ar8answer4"></td><td>&nbsp;<font face="Tahoma" size="2" color="000000"><label for="t78ar8answer4">GamerZone</label></font></td></tr><tr><td width="5"><input type="radio" name="answer" value="5" id="t78ar8answer5"></td><td>&nbsp;<font face="Tahoma" size="2" color="000000"><label for="t78ar8answer5">Mmohut</label></font></td></tr><tr><td colspan="2" height="10"><center><input type="submit" value=" Vote ">&nbsp;&nbsp;<input type="submit" name="view" value=" View "></center></td></tr></a>&nbsp;</font></td></tr></table></form>

    </div>
    <div id="newsfeed">
    <!-- start sw-rss-feed code --> 
    <script type="text/javascript"> 
    <!-- 
    rssfeed_url = new Array();   
    rssfeed_url[0]="http://news.yahoo.com/rss/gaming";
    rssfeed_frame_width="500"; 
    rssfeed_frame_height="720"; 
    rssfeed_scroll="on"; 
    rssfeed_scroll_step="6"; 
    rssfeed_scroll_bar="on"; 
    rssfeed_target="_blank"; 
    rssfeed_font_size="14"; 
    rssfeed_font_face=""; 
    rssfeed_border="on";
    rssfeed_css_url="http://udel.edu/~ssell/newsfeed.css";
    rssfeed_title="on"; 
    rssfeed_title_name=""; 
    rssfeed_title_bgcolor="#3366ff"; 
    rssfeed_title_color="#fff"; 
    rssfeed_title_bgimage="http://"; 
    rssfeed_footer="off"; 
    rssfeed_footer_name="rss feed"; 
    rssfeed_footer_bgcolor="#fff"; 
    rssfeed_footer_color="#333"; 
    rssfeed_footer_bgimage="http://"; 
    rssfeed_item_title_length="50"; 
    rssfeed_item_title_color="#666"; 
    rssfeed_item_bgcolor="#fff"; 
    rssfeed_item_bgimage="http://"; 
    rssfeed_item_border_bottom="on"; 
    rssfeed_item_source_icon="off"; 
    rssfeed_item_date="off"; 
    rssfeed_item_description="on"; 
    rssfeed_item_description_length="120"; 
    rssfeed_item_description_color="#666"; 
    rssfeed_item_description_link_color="#333"; 
    rssfeed_item_description_tag="off"; 
    rssfeed_no_items="0"; 
    rssfeed_cache = "7872565d53aadc6c14b4ab1bb3f79bdb"; 
    //--> 
    </script>
    <script type="text/javascript" src="rss-feed.js"></script> 
    <!-- end sw-rss-feed code -->
    </div>

最佳答案

如果您不想使用响应式设计或类似开关,一个简单的解决方案: 尝试使用以下 CSS 用另一个容器 (#wrapper) 包装容器“#poll”和“#newsfeed”:

#wrapper {
min-width:500px; /* 500px = max. sum of box model width values of #poll and #newsfeed" */
width: auto !important; /* IE>=7 */
width: 500px; /* IE<7 */
}

关于html - 调整大小时如何在不移动的情况下 float 它们?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15249882/

相关文章:

javascript - 计算包括滚动条的窗口宽度 - CSS 媒体查询与 JS

html 从选项中删除带有额外空间的默认选择选项箭头

html - <blink> 的替代方案

android - 如何让这个媒体查询在三星 Galaxy Note4 的不同浏览器中工作相同?

html - 不同的 HTML 元素如何等效?

html - 如何防止移动设备缩放字体大小

html - 左右交替组中的 float 图像和文本在 div 的未知高度中垂直居中对齐

html - 为什么我的 Rails 应用程序上的 Bootstrap 导航栏是垂直的而不是水平的?

css - prefers-reduced-transparency 媒体查询参数的动机是什么

css - IE/ME - 使用 Bootstrap 4 将中间按钮文本与 flex 垂直对齐