html - 调整字体和图片大小

标签 html css responsive-design

我有一个网页,喜欢桌面上的全屏快照。菜单有一些亚洲字体,不用担心。

image1

html:

<header>
    <div class="nav">
        <ul class="menu">
            <li>@Html.ActionLink("主页", "Index", "Home")</li> // asp.net mvc link
            <li>@Html.ActionLink("关于教会", "About", "Home")</li>
            <li>@Html.ActionLink("联系方式", "Contact", "Home")</li>
            <li>@Html.ActionLink("主日证道", "Sermon", "Home")</li>
            <li>@Html.ActionLink("教会活动", "Activity", "Home")</li>
            <li>@Html.ActionLink("社区服务", "Community", "Home")</li>
        </ul>
    </div>
</header>

对应的css:

.nav {
float: left;
}
/* menu
 ----------------------------------------------------------*/
ul.menu {
    font-size: 1em;
    font-weight: 600;
    margin: 0 0 5px;
    padding: 0;
    text-align: right;
 }

 ul.menu li {
    border: 1px solid #FF9933;
    border-bottom-left-radius: 4px;
    border-bottom-right-radius: 4px;
    border-top-left-radius: 4px;
    border-top-right-radius: 4px;
    display: inline;
    list-style: none;
    padding-left: 10px;
    padding-right: 10px;
 }

    ul.menu li a {
        background: none;
        color: #336699;
        text-decoration: none;
    }

        ul.menu li a:hover {
            color: #333;
            text-decoration: none;
        }

 header {
    border-style: solid;
    border-width: 8px;
    background-color: rgb(175, 175, 175);
    background-image: -webkit-linear-gradient(left, #7ac0da 0%, #a4d4e6 100%);
    border-bottom-left-radius: 6px;
    border-bottom-right-radius: 6px;
    border-top-left-radius: 6px;
    border-top-right-radius: 6px;
    color: #336699;
    padding: 20px 40px 30px 40px;
  }

一旦我将它放大到中等大小,图像就变成了: image2

您看到菜单没有挤在一起,我认为是因为字体大小是固定的。如何相应调整呢?是响应式网页设计吗?我刚听说这个词。

另外请注意,图片的大小是固定的,例如 500x400,是否也可以调整?

最佳答案

这是media queries的地方发挥作用,在您的 css 中设置阈值/断点并相应地应用不同的样式

例如:

@media screen and (min-width: 320px) and (max-width: 599px) {
.menu_font
{
font-size:10px; /* set the size as you see fit*/
}
}

==编辑更有意义==

/* menu
 ----------------------------------------------------------*/
 @media screen and (min-width: 320px) and (max-width: 599px) {
ul.menu {
    font-size: 0.75em;
    font-weight: 600;
    margin: 0 0 5px;
    padding: 0;
    text-align: right;
 }
}

关于html - 调整字体和图片大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17654970/

相关文章:

html - 具有 vmin 和移动地址栏的响应式设计

html - 改变元素的位置 - 响应式网站

javascript - 将 css 属性从对象添加到集合

html - 为什么我的 div 消失了?

html - 使用 css 重置时取消重置 css 属性?

jQuery goMap 正在覆盖我的页脚的样式?如何停止?

css - 使图像高度响应

html - 我的圆 Angular 旁边的 CSS 像素太多

javascript - 脚本函数不会打开模态

javascript - 在 jQuery 的表中需要一个固定和可滚动的列