将CSS用于随页面增长和缩小的文本和图像

时间:2012-11-20 21:09:14

标签: jquery css html5 css3

理想情况下,文本和图像(底部按钮除外)会随着页面重新调整大小而缩小并保持对齐,但随后会停止缩小其原始大小的某个百分比。说30%。我愿意使用CSS或jQuery或两者兼而有之。

最好/最干净的方法是什么?

请参阅我的代码:http://jsfiddle.net/ZZCMV/

OR:

HTML:

<html><head></head><body id="page_welcome">
<div class="wrapper">    
<div class="main">
    <div class="logo"><img src="https://qa.tweetcaster.com/assets/img/home/logo.png"></div>
    <div class="tagline">
        <div>The best thing to happen to Twitter since Twitter</div>
    </div>
    <div class="footer">
        <div class="download">
            <div>Over 10 million users! Get TweetCaster FREE:</div>
        </div>
        <ul class="devices">
            <li><a href="https://play.google.com/store/apps/details?id=com.handmark.tweetcaster&referrer=utm_source%3DTCwebsite%26utm_medium%3Dweb%26utm_campaign%3DTCwebsite" target="_blank"><img src="https://qa.tweetcaster.com/assets/img/home/play_store.png" alt="TweetCaster for Android"></a></li>
            <li><a href="http://itunes.apple.com/us/app/tweetcaster-for-twitter/id420792544?mt=8" target="_blank"><img src="https://qa.tweetcaster.com/assets/img/home/app_store.png" alt="TweetCaster for iPhone and iPad"></a></li>
            <li><a href="/login" id="web"><img src="https://qa.tweetcaster.com/assets/img/home/web.png" alt="TweetCaster web app"></a></li>
            <li>
                <button id="dropdown_button" class="menu_button"><img src="https://qa.tweetcaster.com/assets/img/home/more.png" alt="More" ></button>                    
            </li>
        </ul>
        <div class="links">
            <a href="http://tweetcaster.uservoice.com/forums/183240-tweetcaster-web" class="feedback" target="_blank">Feedback</a> &#169;
            <a href="http://onelouder.com" target="_blank">Onelouder</a> 
            <a href="http://tweetcaster.com/privacy" target="_blank">Privacy</a>
            <a href="http://onelouder.com/#terms" target="_blank">Terms</a> 
            <a href="http://onelouder.com/#about" target="_blank">About</a> 
            <a href="http://support.onelouder.com" target="_blank">Help</a> 
        </div>
    </div>
</div>
<div class="bird"><img src="https://qa.tweetcaster.com/assets/img/home/bird.png" alt="TweetCaster"></div>
</div>
</body>
</html>

CSS:

    html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, canvas, details, embed, figure, figcaption, footer, header, hgroup, menu, nav, output, ruby, section, summary, time, mark, audio, video {
    margin: 0;
    padding: 0;
    border: 0;
    vertical-align: baseline;
}
body {
    background: #7bc5ef url(https://qa.tweetcaster.com/assets/img/layout/bg.jpg) center top repeat-x;
    padding-top: 15%;
    font-family: Helvetica, Arial, sans-serif;
}
.main {
    float: left;
    top: 0px;
    margin-left: 0;
    width: 550px;
}
.wrapper {
    text-align: center;
    height: 100%;
    position: relative;
    margin-left: auto;
    margin-right: auto;
    width: 800px;
}
.logo {
    margin: 30px 0px 0px;
}
.tagline {
    font-size: 40px;
    color: #ffffff;
    text-shadow: 0px 2px 2px rgba(0,0,0, 10);
    font-weight: 700;
    width: 510px;
    margin-left: auto;
    margin-right: auto;
}
.footer {
    bottom: 0px;
    width: 550px;
    left: 0px;
    margin-top: 30%;
    padding-bottom: 20px;
}
.download {
    padding-top: 0px;
    text-align: center;
    color: #000000;
    font-size: 22px;
    margin-bottom: 10px;
    font-weight: 700;
}
.links {
    text-align: center;
    font-size: 14px;
}
.links a {
    padding-right: 5px;
    color: #282828;
    text-decoration: none;
}
.links a:hover {
    text-decoration: underline;
}
.feedback {
    font-weight: 700;
    padding-right: 10px;
}
.devices li {
    display: inline-block;
    display: inline; /*ie7 fix */
    padding-right: 7px;
}
.devices {
    margin-left: 15px;
    display: block;
    margin-bottom: 30px;
}
.other_devices {
    display: block;
    margin: 0 0 0 5px;
}
.other_devices li {
    display: inline-block;
    display: inline; /*ie7 fix */
    padding-right: 6px;
}
.bird img {
    float: right;
    max-width: 100%;
    height: auto;
    width: auto\9; /* ie8 */
    float: right;
    bottom: 0;
    position: fixed;
    z-index: -10;
    _position: absolute;
    _top:expression(eval(document.documentElement.scrollTop+ (document.documentElement.clientHeight-this.offsetHeight)));
    height: 80%;
    margin-left: -4%;
    min-height: 400px;
    min-width: 181px;
}
.menu_button {
    background: none;
    border: none;
    margin-left: -7px;
    cursor: pointer;
}
.hidden_menu {
    background-color: white;
    color: #000;
    height: 328px;
    position: absolute;
    display: none;
    margin-top: 0px;
    width: 480px;
    border: 1px solid #999999;
    left: 40px;
    top: 89px;
    box-shadow: 0 2px 9px rgba(0, 0, 0, .75);
}
 .get_tc {
    color: #222222;
    font-size: 20px;
    text-align: center;
    margin-top: 36px;
    margin-bottom: 14px;
}
.dd_arrow {
    position: absolute;
    margin-left: 420px;
    margin-top: 3px;
}
.tc_pink {
    padding-top: 6px;
    margin-bottom: 20px;
}
.get_tc {
    margin-bottom: 10px;
}
.windows_button {
    border-radius: 7px;
}
.clear:before, .clear:after {
    content: ".";
    display: block !important;
    height: 0;
    overflow: hidden;
}
.clear:after {
    clear: both;
}
.clear {
    zoom: 1;
} /* IE < 8 */
p {
    margin-bottom: 18px;
}
p:first-child {
    margin-bottom: 18px;
}
h1 {
    font-size: 20px;
    line-height: 26px;
    font-weight: normal;
}
table, p, h1, h2, h3, h4, caption {
    color: #888;
}
​

1 个答案:

答案 0 :(得分:1)

利用CSS3媒体查询根据浏览器和/或设备大小调整页面大小。 这是一篇很棒的文章,可以帮助您入门:http://css-tricks.com/css-media-queries/

对于图像,如果您设置一个宽度为页面百分比的容器,您可以将以下内容添加到页面css中,以使其重新占用并调整窗口大小。

img {
    max-width: 100%;
    height: auto;
}

这样可以在不使用媒体查询的情况下调整图片大小,但如果您正在寻找更适合每种浏览器/设备尺寸的图片,那么您肯定希望使用媒体查询。

希望这有帮助!