You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何将图片移至“EMAIL :”旁并构建BITLAB NEWS HTML+CSS布局页面

BITLAB NEWS布局调整实现方案

需求说明

将指定图片移动到网站顶部的“EMAIL :”文本旁,同时优化BITLAB NEWS的整体页面布局。

修改后的完整代码

HTML代码

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>BITLAB NEWS</title>
    <link rel="stylesheet" href="styles.css">
</head>
<body>
    <!-- 顶部导航栏 -->
    <div class="top-bar">
        <div class="left">BITLAB NEWS</div>
        <div class="right">About&nbsp;&nbsp;&nbsp;&nbsp; Contacts&nbsp;&nbsp;&nbsp;&nbsp; FAQ&nbsp;&nbsp;&nbsp;&nbsp; Login&nbsp;&nbsp;</div>
    </div>

    <!-- 登录区域 -->
    <div class="login-section">
        <div class="login-bar">
            <div class="label">EMAIL :</div>
            <!-- 移动到此处的图片 -->
            <img src="3a.jpg" alt="News Thumbnail" class="login-icon">
        </div>
        <div class="input">
            <input type="text" placeholder="Insert Email" style="width:200px; height: 25px;">
        </div>
        <div class="password-bar">
            <div class="label">PASSWORD :</div>
        </div>
        <div class="input2">
            <input type="text" placeholder="Insert Password" style="width:200px; height: 25px;">
        </div>
        <div class="button">
            <div class="signin-btn">SIGN IN</div>
        </div>
        <p>&nbsp;&nbsp;&nbsp;I want to create <span class="blue">new account</span></p>
    </div>
</body>
</html>

CSS代码

/* 全局样式重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

.top-bar {
    background-color: #00008B;
    color: white;
    display: flex;
    justify-content: space-between;
    padding: 10px 20px;
    align-items: center;
}

.top-bar .left {
    color: white;
    font-weight: bold;
    font-size: 20px;
}

.top-bar .right {
    color: white;
}

/* 登录区域容器 */
.login-section {
    padding: 20px;
    max-width: 400px;
}

.login-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
}

.login-bar .label {
    color: black;
    font-weight: 500;
}

/* EMAIL旁的图片样式 */
.login-icon {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: 4px;
}

.input {
    padding-left: 0;
    margin-bottom: 20px;
}

.password-bar {
    padding: 10px 0;
}

.password-bar .label {
    color: black;
}

.input2 {
    padding-left: 0;
    padding-top: 10px;
    margin-bottom: 20px;
}

.button {
    background-color: green;
    color: white;
    width: 80px;
    border-radius: 5px;
    font-size: 12px;
    text-align: center;
    padding: 10px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.button:hover {
    background-color: #006400;
}

.blue {
    color: #0000FF;
    cursor: pointer;
}

关键修改点说明

  • 图片移动与布局:将原新闻区域的图片移至login-bar容器内,通过display: flex和align-items: center实现图片与“EMAIL :”文本的垂直对齐,同时用gap设置间距。
  • HTML结构修复:将原外部的top-bar移入<body>标签内,补充完整的HTML文档结构(DOCTYPE、head标签),确保页面规范。
  • 布局优化:新增login-section容器包裹登录相关元素,统一内边距;移除原浮动布局的center容器,简化结构;调整表单元素的padding和margin,让布局更规整。
  • 细节优化:添加全局样式重置(* {box-sizing: border-box})避免布局冲突;给按钮添加hover效果提升交互性;调整图片尺寸为40x40px,适配顶部区域大小。

内容的提问来源于stack exchange,提问作者Rrrss

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.01 16:05:53