English 中文(简体)
当浏览器分辨率低于 1260px 时调整 h1 的字体大小
原标题:Resize font size of h1 when browser resolution is below 1260px
  • 时间:2012-05-22 16:09:14
  •  标签:
  • css

I m stuck, I am designing a webpage on resolution 1266px. I want it to fit on 1024px because 13% of the people are still using that resolution. So I thought I could change the fontsize of my h1 and my nav_items.

因此,如果决议低于1260,它们将合身,我希望它们留在给他们的固定纸条上。

这就是我得到的:

header {
  width:100%;
  background: #222;
  color: white;
  height: 80px;
  margin: 0px 0px 0px 0px;
  padding: 0px 0px 0px 0px; 
  -webkit-box-shadow: 0 1px 10px rgba(0, 0, 0, 0.6);
  -moz-box-shadow: 0 1px 10px rgba(0, 0, 0, 0.6);
  box-shadow: 0 1px 10px rgba(0, 0, 0, 0.6);
  text-shadow: 2px 2px 0 #000;
}
header h1 { /* TAVERNE DE STADSPOORT */
  font-size: 40px;
  float:left;
  color:white;
  margin: 0px 0px 0px 0px; /* top, left, bottom, right*/ 
  padding: 10px 30px 10px 20px; /* top, right, bottom, right*/
}
header ul {
  float: right; 
  width: 680px;
  padding: 20px; 0px; 0px; 0px; /* top, left, bottom, right*/
}
.nav_items li {
  display:inline;
  font-size:22px;
  margin: 0px 4px 0px 4px; /* top, left, bottom, right (outside) */ 
  padding: 0px 4px 0px 4px; /* top, left, bottom, right*/ 
}

<div id="logo">
<h1 class="nav_items"><a href="index.html">Taverne De Stadspoort</a></h1>
</div>
<nav id="top">
    <ul class="nav_items">
        <li><a href="/">Menukaart</a></li>
        <li><a href="/">Suggesties</a></li>
        <li><a href="/">Onze wijnen</a></li>
        <li><a href="/">Ligging/contact</a></li>
        <li><a href="/">Gastenboek</a></li>
    </ul>
</nav>

Maybe I did something wrong, and I could resolve this problem a other way. Or should I use jquery instead for archieving this? since I am not familair with that an other solution would be great.

i 添加以下内容:

@media all and (max-width: 1259px) { h1 { font-size: 25px; } }
@media all and (min-width: 1260px) { h1 { font-size: 40px; } } 
/* http://www.w3.org/TR/css3-mediaqueries/ */
最佳回答

E.g 等

@media all and (min-width: 1266px) {

    h1 {
      font: (large-size)px;
    }
}

@media all and (max-width: 1265px) {

    h1 {
      font: (smaller-size)px;
    }
}
问题回答

查看“https:// developmenter.mozilla.org/en/CSS/Media_queries” rel=“nofollow”>>CSS媒体查询。他们允许您指定特定屏幕分辨率的样式(更多) 。

$( #fit ).resizable({
    resize: function( event, ui ) {

        divWidth = ui.size.width/(len*9);
        divHeight = ui.size.height / (len *2.2);

        abc = divWidth;
        if (divWidth < divHeight) { 
          abc = divWidth; 
        } else {
            abc = divHeight
        }

        ui.element.css({ font-size : abc + em });
        console.log(abc);

    }
});




相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

jquery ui dialog opens only once

I have a button that opens a dialog when clicked. The dialog displays a div that was hidden After I close the dialog by clicking the X icon, the dialog can t be opened again.

Drop down background url in Safari Issue

selectBox.selectCSS { background: url(/Images/replacementSelectBackground.png) top left no-repeat height:auto; } I have an issue in Safari only where the image is not rendering on top ...

CSS specific for Safari

How do you target specifically safari in css with styles?

Aligning textarea in a form

Ive used the following css code to align my form elements: form { position:relative; } form input { position:absolute; left:11em; } However, the textarea element is not aligned correctly with the ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

CSS problem with page footer

I have defined my page footer in the css file as: #footer { position: absolute; height: 50px; text-align: center; background: #66CCCC; bottom: 0px; left: 0px; width: 100%; height: ...

热门标签