如何在徽标旁边的标题菜单中插入搜索栏。请告诉我我做错了什么?

时间:2014-12-10 07:35:07

标签: css html5

您好我是这个网站的新手,也是一般的编程新手。我目前正在尝试将这个网站(只是练习)放在一起,但我似乎陷入了困境,我无法将搜索栏移到徽标旁边。我知道我的菜单项也不正确,我将在我解决此搜索栏问题后重试它们。 我目前要打开一个index.html和一个style.css

文件

以下是html.index页面。


<!doctype html>
<html>
    <head>
        <title>FindFriends</title>
        <link rel="stylesheet" type="text/css" href="./css/style.css" />
    </head>
    <body>
        <div class="headerMenu">
            <div id="wrapper">
                <div class="logo">
                        <img src="./img/find_friends_logo.png"/>
                    </div>
                    </div class="search_box" />
                                <form action="search.php" method="GET" id="search">
                                    <input type="text" name="q" size="60" placeholder="Search."/>
                                </form>
                            </div>
                            <div id="menu">
                            <a href="#" />Home</a>
                            <a href="#" />About</a>
                            <a href="#" />Sign Up</a>
                        </div>
                    </div>
            </div>
            <div style="width: 800px; margin: 0px auto 0px auto;">
            <table>
                <tr>
                    <td width="60%" valign="top">
                        <h2>Join Find Friends Today</h2>
                    </td>
                    <td width="%" valign="top">
                        <h2>Sign Up Below</h2>  
                        <form action="#" method="POST">
                            <input type="text" name="fname" size="25" placeholder="First Name" /><br /><br />
                            <input type="text" name="lname" size="25" placeholder="Last Name" /><br /><br />
                            <input type="text" name="username" size="25" placeholder="Username" /><br /><br />
                            <input type="text" name="email" size="25" placeholder="Email" /><br /><br />
                            <input type="text" name="email2" size="25" placeholder="Confirm Email" /><br /><br />
                            <input type="text" name="password" size="25" placeholder="Password" /><br /><br />
                            <input type="text" name="password2" size="25" placeholder="Confirm Password" /><br /><br />
                            <input type="submit" name="submit" value="Sign Up!" >
                        </form>
                    </td>
                </tr>
                </div>
            </table>
    </body>
</html>

这是下面的style.css页面。


* {
    margin: 0px;
    padding: 0px;
    font-family: Arial, Helvetica, Sans-serif;
    font-size: 12px;
    background-color: #eff5f9;
}
.headerMenu {
        background-image: url(../img/menu_bg.png);
        height: 50px;
        border-bottom: 0px;
        padding-left: auto;
        padding-right: auto;
        width: 100%;
}
#wrapper {
        background-image: url(../img/menu_bg.png);
        margin-left: auto;
        margin-right: auto;
        width: 1000px;
        padding-top: 0px;
        padding-bottom: 0px;
}
.logo {
        background-image: url(../img/menu_bg.png);
        width: 125px;
}
.logo img {
        background-image: url(../img/menu_bg.png);
        width: 150px;
        height: 38px;
        padding-top: 5px;


}

        .search-box {
        background-image: url(../img/menu_bg.png);
        position: absolute;
        top: 13px;
        margin-left: 135px;

}



    #search input[type="text"] {
    background: url(../img/search_dark.png) no-repeat 10px 6px #267bb6;
    outline: none;
    border: 0 none;
    font: bold 12px Arial,Helvetica,Sans-serif;
    width: 350px;
    padding: 9px 15px 9px 35px;
    margin: 0;
    text-shadow: 0 2px 2px rgba(0, 0, 0, 0.3);
    -webkit-box-shadow: 0 1px 0 rgba(255, 255, 255, 0.1), 0 1px 3px rgba(0, 0, 0, 0.2) inset;
    -moz-box-shadow: 0 1px 0 rgba(255, 255, 255, 0.1), 0 1px 3px rgba(0, 0, 0, 0.2) inset;
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.1), 0 1px 3px rgba(0, 0, 0, 0.2) inset;
    -webkit-transition: all 0.7s ease 0s;
    -moz-transition: all 0.7s ease 0s;
    -o-transition: all 0.7s ease 0s;
    transition: all 0.7s ease 0s;
    }
    #search input[type="text"]:focus {
    background: url(../img/search_light.png) no-repeat 10px 6px #fcfcfc;
    color: #6a6f75;
    width: 350px;
    -webkit-box-shadow: 0 1px 0 rgba(255, 255, 255, 0.1), 0 1px 0 rgba(0, 0, 0, 0.9) inset;
    -moz-box-shadow: 0 1px 0 rgba(255, 255, 255, 0.1), 0 1px 0 rgba(0, 0, 0, 0.9) inset;
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.1), 0 1px 0 rgba(0, 0, 0, 0.9) inset;
    text-shadow: 0 2px 3px rgba(0, 0, 0, 0.1);
 }
 @media screen and (max-width: 1280px) {
  #menu {
    background-image: url(../img/menu_bg.png);
    position: absolute;
    top: 0px;
    right: 0px;
    height: 37px;
    padding-top: 19px;
    margin-right: 2%;

}
}
 @media screen and (min-width: 1280px) {
  #menu {
    background-image: url(../img/menu_bg.png);
    position: absolute;
    top: 0px;
    right: 0px;
    height: 37px;
    padding-top: 18px;
    margin-right: 3%;
}
}
 @media screen and (max-width: 1920px) {
  #menu {
    background-image: url(../img/menu_bg.png);
    position: absolute;
    top: 0px;
    right: 0px;
    height: 37px;
    padding-top: 15px;
    margin-right: 4%;

}
}
 #menu a {
    color: #FFFFFF;
    text-decoration: name;
    font-size: 14px;
    background-image: url(../img/menu_bg.png);
    background-repeat: no-repeat;
    padding-top: 19px;
    padding-bottom: 22px;
    padding-left: 10px;
    padding-right: 10px;
}
#menu a:hover {

    background-image: url(../img/menu_bg_hover_mouse_over.png);

}
h2 {
    font-family: Arial, Helvetica, Sans-serif;
    font-size: 18px;
    padding: 8px;
    color: #0084c6;
}
input[type="text"] {
    background-color: #FFFFFF;
    border: 1px solid #E2E2E2;
    font-size: 15px;
    padding: 5px;
    width: 300px;
    margin-bottom: 3px;
    margin-top: 3px;
    outline: none;
}
input[type="text"]:hover {
    border: 1px solid #006fc4;
}
input[type="submit"] {
    background-color: #006FC4;
    border: 1px solid #00508D;
    font-size: 15px;
    color: #FFFFFF;
    padding: 5px;
    margin-bottom: 3px;
    margin-top: 3px;
    border-radius: 7px;
}

提前感谢您的帮助。

2 个答案:

答案 0 :(得分:0)

在html和css中检查您的班级名称之后,您应该在徽标div和搜索框div中使用css float:left;属性

答案 1 :(得分:0)

我已经更正了你的HTML,我希望我没有错过任何东西。

<!doctype html>
<html>
<head>
<title>FindFriends</title>
<link rel="stylesheet" type="text/css" href="./css/style.css" />
</head>


    <body>

        <div class="headerMenu">

            <div id="wrapper">


                <div class="logo">
                        <img src="./img/find_friends_logo.png"/>
                    </div>

                    <div class="search_box">
                                <form action="search.php" method="GET" id="search">
                                    <input type="text" name="q" size="60" placeholder="Search." />
                                </form>
                    </div>
                            <div id="menu">
                            <a href="#" >Home</a>
                            <a href="#" >About</a>
                            <a href="#" >Sign Up</a>

                            </div>

            </div>

        </div>

            <div style="width: 800px; margin: 0px auto 0px auto;">
            <table>
                <tr>
                    <td width="60%" valign="top">
                        <h2>Join Find Friends Today</h2>
                    </td>
                    <td width="40%" valign="top">
                        <h2>Sign Up Below</h2>  
                        <form action="#" method="POST">
                            <input type="text" name="fname" size="25" placeholder="First Name" /><br /><br />
                            <input type="text" name="lname" size="25" placeholder="Last Name" /><br /><br />
                            <input type="text" name="username" size="25" placeholder="Username" /><br /><br />
                            <input type="text" name="email" size="25" placeholder="Email" /><br /><br />
                            <input type="text" name="email2" size="25" placeholder="Confirm Email" /><br /><br />
                            <input type="text" name="password" size="25" placeholder="Password" /><br /><br />
                            <input type="text" name="password2" size="25" placeholder="Confirm Password" /><br /><br />
                            <input type="submit" name="submit" value="Sign Up!" >
                        </form>
                    </td>
                </tr>

            </table>
            </div>
    </body>
</html>

对于CSS来说,那里也有很多错误。但我会回答你的问题:

.logo {
        width: 150px;
        float:left;
}
.search-box {
        background-image: url(../img/menu_bg.png);
        position: absolute;
        top: 13px;
        margin-left: 135px;
          float:left;

}

我建议重写css,因为它有很多错误。有些事情要记住: 1.为什么你有徽标3徽标图像?一个来自html,两个作为背景图像?(只需要一个图像)。 2.在包含div的情况下,如果没有位置相对,则不能使用绝对位置。

<div class="a">
  <div class="b"></div>
</div>
.a{position:relative}
.b{position:absolute}

这就是你应该如何使用potition。Here你有一些位置的文档。希望对你有所帮助