📜  使用 HTML 和 CSS 设计在线食品配送系统网页

📅  最后修改于: 2021-08-30 12:05:21             🧑  作者: Mango

在本文中,我们将学习如何使用 HTML 和 CSS 为在线食品配送系统制作一个完全响应式的网页。

使用的文件:

  • 索引.html
  • 联系方式.html
  • 样式文件

index.html:下面的 HTML 代码描述了网页的结构。首先,它有一个标题标签来显示公司名称,即“Online FoodShop”。导航栏包含“主页”、“关于”、“菜单”和“联系我们”选项卡。导航栏还包括公司的标志和背景图片以及“在线食品商店”的更多细节以及特色产品。

HTML


  

    
    
    
        

  

    
        

Online

        

FoodShop

    
    
         
        
            Welcome to Online FoodShop         
                 
            
                             
            
                             
        
    
    
    

Featured Products

    
        
                     
        
                     
        
                     
    
    
Copyright © 2020-2021 OnlineFoodShop.            All Rights are reserved


HTML


  

    
    
  
    
    ContactUs

  

    
        

Contact Us

        
            
                                              
            
                                              
            
                                              
            
                                              
            
                Are you a member of OnlneFoodShop:                 Yes                 No             
            
                                              
                                  
    
  


contact.html:以下 HTML 代码描述了导航栏中“ContactUs”选项卡中显示的内容。我们使用输入标签来输入查询的“查询”、“姓名”、“电子邮件ID”、“电话号码”和“说明”的类型。我们还使用单选按钮来查询客户的“在线食品商店”会员资格。该表单还提供了“提交”和“重置”按钮。

HTML



  

    
    
  
    
    ContactUs

  

    
        

Contact Us

        
            
                                              
            
                                              
            
                                              
            
                                              
            
                Are you a member of OnlneFoodShop:                 Yes                 No             
            
                                              
                                  
    
  

style.css:这是样式表块,它为我们提供了正确的网页外观。

  • 标题样式:它由两个“head”标签组成。我们使用字体样式“Ubuntu”来设计标题,我们还使用适当的颜色使一些文本看起来很有吸引力。
  • 导航栏样式:它基本上由徽标样式和内容样式组成。首先,我们将导航栏视为一个 flexbox,并将flex-direction分配给“column”。我们通过 display:block将徽标图像居中。我们使用了margin:auto属性来使图像居中。然后我们将导航栏的内容视为一个 flexbox,然后我们将其正确定位。
  • 背景图片样式:我们使用之前的伪选择器来设置相应的背景图片。
    /*CSS Reset*/
    *{
        margin:0px;
        padding:0px;
    }
    /*Header Styling*/
    
    #top{
        color:rgb(245, 10, 10);
        text-align:center;
        font-size:46px;
        font-family: 'Ubuntu Mono', monospace;
    }
    #top1{
        text-align:center;
        color:black;
        font-size:21px;
        font-family: 'Ubuntu Mono', monospace;
    }
    /* Navigation bar styling*/
    
    /*Navbar image styling*/
    #navbar img{
        display:block;
        width: 50px;
        height:50px;
        margin:auto;
        margin-bottom: 3px;
    }
    
    /*Navbar Functionality*/
    #navbar{
        display:flex;
        flex-direction: column;
        background-color: gray;
        height: 14vh;
        width: 100vw;
        font-family: 'Ubuntu Mono', monospace;
        margin-top:10px;
       border: 2px solid black;
       border-radius:15px;
    }
    
    
    /*Navbar content functionality*/
    #navcontent{
        display: flex;
        justify-content: center;
    }
    
    
    /*Navbar content styling*/
    ul li{
        list-style: none;
        margin: 15px;
        border-radius: 20px;
    }
    ul li a{
        padding: 1px;
        color:white;
        text-decoration: none;
        border-radius:10px;
    }
    ul li a:hover{
        background-color: red;
        border-radius: 10px;
    }
    
    /* website background image designing */
    #container1{
        position: relative;
        display: flex;
        flex-direction: column;
        align-items: center;
        width: 100vw;
        height:63vh;
    }
    
    /*Setting the background image using before pseudo selector*/ 
    #container1::before{
        content:'';
        background: url("./1.jpg") no-repeat center center/cover;
        width: 100vw;
        height:59vh;
        position: absolute;
        top:0px;
        left: 0px;
        font-family: 'Ubuntu Mono', monospace;
        margin-right:45px;
        font-weight: bold;
        z-index: -1;
        opacity: 0.89;
        border: 2px solid black;
        border-bottom-left-radius: 100px;
    }
    
    #row1{
       color: black;
        font-weight:bold;
        font-size: 2rem;
        text-align: center;
        margin-top: 35px;
    }
    /*Button Styling*/
    .btn{
        margin-top:15px;
        border: 3px solid white;
        border-radius:15px;
        background-color:yellow;
        font-size:20px;
        font-weight: bold;
        font-family: 'Ubuntu Mono', monospace;
    }
    .btn:hover{
        cursor: pointer;
        background-color: red;
    }
    
    
    #container3{
        display: flex;
        justify-content: space-evenly;
    }
    #row2{
        width:24vw;
        height:21vh;
        box-shadow: 2px 7px 16px 19px;
         margin-top:51px;
         margin-bottom: 51px;
         display: flex;
        justify-content: center;
         align-items: flex-end;
         position: relative;
         margin-right: 38px;
         border-radius: 40px;
    }
    #row2::before{
        content: '';
        background: url('2.jpeg') no-repeat center center/cover;
        position: absolute;
        top: 0px;
        left:0px;
        width: 24vw;
        height:21vh;
        z-index: -1;
        border-radius: 40px;
    }
    #row3{
        position: relative;
        width: 24vw;
        height:21vh;
        display: flex;
        justify-content: center;
         align-items: flex-end;
         box-shadow: 2px 7px 16px 19px;
         margin-top:51px;
         margin-bottom: 51px;
         
         margin-left: 38px;
         border-radius: 40px;
    }
    #row3::before{
        content: '';
        background: url('3.jpeg') no-repeat center center/cover;
        position: absolute;
        top:0px;
        left:0px;
        width: 24vw;
        height:21vh;
        z-index: -1;
        border-radius: 40px;
    }
    
    #top3{
        text-align: center;
        color:red;
        font-family: 'Ubuntu Mono', monospace;
    }
    #container4{
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
        margin: 41px;
    }  
    #row4{
        width: 29vw;
        height: 360px;
        border: 2px solid black;
        background:url('a1.jpeg') no-repeat center center/cover; 
        display: flex;
        justify-content:center;
        align-items:flex-end;
        border-radius: 15px;
    }
    #row5{
        width: 29vw;
        height: 360px;
        border: 2px solid black;
        background:url('a2.jpeg') no-repeat center center/cover;
        display: flex;
        justify-content:center;
        align-items:flex-end;
        border-radius: 15px;
    }
    #row6{
        width: 30vw;
        height: 360px;
        border: 2px solid black;
        background:url('a3.jpeg') no-repeat center center/cover;
        display: flex;
        justify-content:center;
        align-items:flex-end;
        border-radius: 15px;
    }
    /*Designing the footer*/
    footer{
        text-align: center;
    }
    /*Designing of Contact Us*/
    #ContactUs{
        width:100vw;
        height:100vh;
        display:flex;
        flex-direction: column;
        align-items: center;
        background-color: gray;
    }
    .form-shape input, .form-shape select, .form-shape textarea{
       width: 92%;
       padding: 0.5rem;
    }
    /*Changing the color of placeholder*/
    ::placeholder{                  
        color:gray;
    }
    /*Making the webpage responsive using media quries*/
    @media only screen and (max-width:1131px){
        #row4{
            width: 42vw;
        }
        #row5{
            width:45vw;
        }
        #row6{
            margin-top: 20px;
            width:90vw;
        }
    }
    @media only screen and (min-width:600px) and (max-width:781px)
    {
        #row4{
            width:84vw;
            margin: auto;
            margin-left: 22px;
        }
        #row5{
            
            width:84vw;
            margin: auto;
            margin-top: 20px;
            margin-left: 22px;
        }
        #row6{
            width:84vw;
            margin: auto;
            margin-top: 20px;
            margin-left: 22px;
        }
    }
    @media only screen and (max-width:600px){
        #row4{
            width:78vw;
            margin: auto;
            margin-left: 3px;
        }
        #row5{
            
            width:78vw;
            margin: auto;
            margin-top: 20px;
            margin-left: 3px;
        }
        #row6{
            width:78vw;
            margin: auto;
            margin-top: 20px;
            margin-left: 3px;
        }
    }
    @media only screen and (min-height:1000px){
        #navbar{
            height:10vh;
        }
        #container1::before{
            height:39vh;
        }
        #container1{
            height:44vh
        }
    }
    

    输出:

    • 15.6 英寸笔记本电脑:
    • iPhone 6/7/8 加:
    • iPad Pro: