我不能移动我的div了吗?但我可以左右移动它吗?

时间:2018-02-16 06:40:44

标签: html css

我正在尝试设计一个简单的网站,并且我已经制作了一个带有磨砂玻璃效果的div,现在我可以左右定位但我似乎无法将它移动起来!?有问题的div有产品面板的名称。



*{
    margin: 0;
    padding: 0;
   }

.background{
    background-image: url("http://www.kubipet.com/data/out/55/iwp779807523-electrical-wallpapers.jpg");
    background-repeat: no-repeat;
    background-attachment: fixed;
    background-size: cover;
}


#header-frosted{
    background: inherit;
    position: relative;
    width:100%;
    height: 200px;
   
}



    
.jumbotron-fluid{
   background: inherit; 
   padding-left: 0px;
   padding-right:0px;
   padding-top:0px;
   padding-bottom: 0px;
   margin-bottom: 0px;
   width: 100%;  
   color:rgb(0, 0, 0);
   
}


.display-3{
    text-align: center;
    margin-top:50px;
    
}


.navbar.main {
  
   background-color:rgb(0, 0, 0);
    color: rgb(255, 255, 255);
    margin-top: 0px;
    border-style: none;
    border-radius: 0%;
    
    
}
.nav-pills{
 margin-top:2px;
text-align: center;
margin-top:5px;
margin-bottom: 0px;
}

#tab{
    color: white;    
}

#tab:hover {
    background-color: rgb(63, 60, 60);
}



.frosted-glass {
    
    width:10%;
    height:auto;
    background: inherit;
    position: relative;
    z-index: 1;
    overflow: hidden;
    margin: 30px,30px,30px,30px;
    padding: 2rem;
    box-sizing: border-box; 
  }
  
  .frosted-glass::before {
    width:auto;
    height:auto;
    content: "";
    position: absolute;
    z-index: -1;
    top: 0; right: 0; bottom: 0; left: 0;
    background: inherit;
    box-shadow: inset 0 0 3000px rgba(255,255,255,.5);
    filter: blur(5px);

  }
  #product-panel{
    width:500px;
    height: 400px;
    text-align:left;
    position: absolute;
    margin-top:20px;
  
   
   
    

}
#contact-details{
    width:200px;
    height: 330px;
    text-align:left;
    margin-left: auto;
    margin-bottom: 100px;
    position: relative;
    
  }

  #details{
    text-align: center;
}

   enter code here

`<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" media="screen" href="fonts\css\font-awesome.min.css">
    <link rel="stylesheet" type="text/css" media="screen" href="css\KAD-css.css">
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <title>Website</title>
</head>

<body class="background">
  
  
        <div class="jumbotron jumbotron-fluid frosted-glass" id="header-frosted" >
                <div class="container img-responsive">
                  
                  <h1 class="display-3">Random Title</h1>
                  
                </div>
              </div>

              <nav class="navbar navbar-expand-lg navbar-dark  navbar-default main" >
                  <div class="container-fluid">
                    <div class="navbar-header">
                      <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span> 
                      </button>
                      <a class="navbar-brand" href="#"id="tab">Random Title</a>
                    </div>
                    <div class="collapse navbar-collapse text-centre" id="myNavbar">
                      <ul class="nav  nav-pills center-pills">
                          <li class="nav-item ">

  
                              <a class="nav-link" href="#" id="tab"> Random1
                               
                              </a>
                            </li>
                            <li class="nav-item ">

  
                                <a class="nav-link" href="#"id="tab"> Random2
                                 
                                </a>
                              </li>
                              <li class="nav-item">

  
                                  <a class="nav-link" href="#"id="tab"> Random3
    
                                  </a>
                                </li>
                      </ul>
                      <ul class="nav navbar-nav navbar-right">
                        
                      </ul>
                    </div>
                  </div>
                </nav>'

<div class="frosted-glass" id="contact-details">
   <h3 id="details">Contact Details</h3>
 <p><strong>Name:</strong>John Doe</p>
 <p><strong>Phone Number:</strong> 000000000</p>
 <h3>Address:</h3>
 <strong><p>Random Title.</p>
 <p>PO Box 000</p>
 <p>Random Town, Random Country</p>
 <p>000</p>
 </strong>
</div>
 <!--Product Panel-->
<div class="frosted-glass" id="product-panel">
This is the div in question.


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




    

 
&#13;
&#13;
&#13;

请记住,我刚刚开始使用网页设计一些帮助和输入,非常感谢。

4 个答案:

答案 0 :(得分:1)

<!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta http-equiv="X-UA-Compatible" content="ie=edge">
        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
        <link rel="stylesheet" type="text/css" media="screen" href="fonts\css\font-awesome.min.css">
        <link rel="stylesheet" type="text/css" media="screen" href="css\KAD-css.css">
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
        <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
        <title>Website</title>      
            <!-- begin snippet: js hide: false console: true babel: false -->
            <!-- language: lang-css -->
        <style>
                *{
                    margin: 0;
                    padding: 0;
                   }

                .background{
                    background-image: url("http://www.kubipet.com/data/out/55/iwp779807523-electrical-wallpapers.jpg");
                    background-repeat: no-repeat;
                    background-attachment: fixed;
                    background-size: cover;
                }
                #header-frosted{
                    background: inherit;
                    position: relative;
                    width:100%;
                    height: 200px;                 
                }                   
                .jumbotron-fluid{
                   background: inherit; 
                   padding-left: 0px;
                   padding-right:0px;
                   padding-top:0px;
                   padding-bottom: 0px;
                   margin-bottom: 0px;
                   width: 100%;  
                   color:rgb(0, 0, 0);                 
                }
                .display-3{
                    text-align: center;
                    margin-top:50px;                
                }
                .navbar.main {                
                   background-color:rgb(0, 0, 0);
                    color: rgb(255, 255, 255);
                    margin-top: 0px;
                    border-style: none;
                    border-radius: 0%;
                }
                .nav-pills{
                 margin-top:2px;
                text-align: center;
                margin-top:5px;
                margin-bottom: 0px;
                }

                #tab{
                    color: white;    
                }

                #tab:hover {
                    background-color: rgb(63, 60, 60);
                }
                .frosted-glass {

                    width:10%;
                    height:auto;
                    background: inherit;
                    position: relative;
                    z-index: 1;
                    overflow: hidden;
                    margin: 30px,30px,30px,30px;
                    padding: 2rem;
                    box-sizing: border-box;
                  }               
                  .frosted-glass::before {
                    width:auto;
                    height:auto;
                    content: "";
                    position: absolute;
                    z-index: -1;
                    top: 0; right: 0; bottom: 0; left: 0;
                    background: inherit;
                    box-shadow: inset 0 0 3000px rgba(255,255,255,.5);
                    filter: blur(5px);

                  }
                  #product-panel{
                    width:500px;
                    height: 400px;
                    text-align:left;
                    position: absolute;
                    margin-top:20px;
                }
                #contact-details{
                    width:200px;
                    height: 330px;
                    text-align:left;
                    margin-left: auto;
                    margin-bottom: 100px;
                    position: relative;

                  }

                  #details{
                    text-align: center;
                }
                /*
                Start of Code - Laxmikant Killekar
                */
                body{
                    overflow-x: hidden;
                }
                /*
                End of Code - Laxmikant Killekar
                */

        </style>
    </head>
    <body class="background">
        <div class="jumbotron jumbotron-fluid frosted-glass" id="header-frosted" >
            <div class="container img-responsive">            
              <h1 class="display-3">Random Title</h1>             
            </div>
          </div>
          <nav class="navbar navbar-expand-lg navbar-dark  navbar-default main" >
              <div class="container-fluid">
                <div class="navbar-header">
                  <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span> 
                  </button>
                  <a class="navbar-brand" href="#"id="tab">Random Title</a>
                </div>
                <div class="collapse navbar-collapse text-centre" id="myNavbar">
                    <ul class="nav  nav-pills center-pills">
                        <li class="nav-item ">
                          <a class="nav-link" href="#" id="tab"> Random1</a>
                        </li>
                        <li class="nav-item ">
                            <a class="nav-link" href="#"id="tab"> Random2 </a>
                        </li>
                        <li class="nav-item">
                          <a class="nav-link" href="#"id="tab"> Random3</a>
                        </li>
                    </ul>
                    <ul class="nav navbar-nav navbar-right">                        
                     </ul>
                </div>
              </div>
            </nav>

            <!-- Start of Code - Laxmikant Killekar -->             

            <div class="fluid-container">
                <div class="row">
                    <div class="col-md-6">
                    <!--Product Panel-->
                        <div class="frosted-glass" id="product-panel">
                        This is the div in question.                          
                        </div>
                    </div>
                    <div class="col-md-4 pull-right">
                        <div class="frosted-glass" id="contact-details">
                             <h3 id="details">Contact Details</h3>
                             <p><strong>Name:</strong>John Doe</p>
                             <p><strong>Phone Number:</strong> 000000000</p>
                             <h3>Address:</h3>
                             <strong><p>Random Title.</p>
                             <p>PO Box 000</p>
                             <p>Random Town, Random Country</p>
                             <p>000</p>
                             </strong>
                        </div>
                    </div>

                </div>
            </div>
            <!--End of Code - Laxmikant Killekar-->

        </body>
    </html>

答案 1 :(得分:0)

将top:(value)px添加到此

new Date(Date.now() + 604800000);

你可以改变位置

&#13;
&#13;
 #product-panel{
    width:500px;
    height: 400px;
    text-align:left;
    position: absolute;
    margin-top:20px;
    top:320px;
}
&#13;
*{
    margin: 0;
    padding: 0;
   }

.background{
    background-image: url("http://www.kubipet.com/data/out/55/iwp779807523-electrical-wallpapers.jpg");
    background-repeat: no-repeat;
    background-attachment: fixed;
    background-size: cover;
}


#header-frosted{
    background: inherit;
    position: relative;
    width:100%;
    height: 200px;
   
}



    
.jumbotron-fluid{
   background: inherit; 
   padding-left: 0px;
   padding-right:0px;
   padding-top:0px;
   padding-bottom: 0px;
   margin-bottom: 0px;
   width: 100%;  
   color:rgb(0, 0, 0);
   
}


.display-3{
    text-align: center;
    margin-top:50px;
    
}


.navbar.main {
  
   background-color:rgb(0, 0, 0);
    color: rgb(255, 255, 255);
    margin-top: 0px;
    border-style: none;
    border-radius: 0%;
    
    
}
.nav-pills{
 margin-top:2px;
text-align: center;
margin-top:5px;
margin-bottom: 0px;
}

#tab{
    color: white;    
}

#tab:hover {
    background-color: rgb(63, 60, 60);
}



.frosted-glass {
    
    width:10%;
    height:auto;
    background: inherit;
    position: relative;
    z-index: 1;
    overflow: hidden;
    margin: 30px,30px,30px,30px;
    padding: 2rem;
    box-sizing: border-box; 
  }
  
  .frosted-glass::before {
    width:auto;
    height:auto;
    content: "";
    position: absolute;
    z-index: -1;
    top: 0; right: 0; bottom: 0; left: 0;
    background: inherit;
    box-shadow: inset 0 0 3000px rgba(255,255,255,.5);
    filter: blur(5px);

  }
  #product-panel{
    width:500px;
    height: 400px;
    text-align:left;
    position: absolute;
    margin-top:20px;
    top:320px;
   
   
    

}
#contact-details{
    width:200px;
    height: 330px;
    text-align:left;
    margin-left: auto;
    margin-bottom: 100px;
    position: relative;
    
  }

  #details{
    text-align: center;
}
&#13;
&#13;
&#13;

答案 2 :(得分:0)

here 是codepen,告诉我它是否解决了你的问题

把你的 <div class="frosted-glass" id="product-panel">

之前<div class="frosted-glass" id="contact-details">

答案 3 :(得分:0)

当您在一行中使用多个项目时,它应该满足宽度比例 因此,给出宽度百分比'%'而不是像素'px', 在这里你可以使用float:left来包含一行中的多个项目。 尝试使用百分比宽度,这是大多数开发人员使用的方式

*{
    margin: 0;
    padding: 0;
   }

.background{
    background-image: url("http://www.kubipet.com/data/out/55/iwp779807523-electrical-wallpapers.jpg");
    background-repeat: no-repeat;
    background-attachment: fixed;
    background-size: cover;
}


#header-frosted{
    background: inherit;
    position: relative;
    width:100%;
    height: 200px;
   
}



    
.jumbotron-fluid{
   background: inherit; 
   padding-left: 0px;
   padding-right:0px;
   padding-top:0px;
   padding-bottom: 0px;
   margin-bottom: 0px;
   width: 100%;  
   color:rgb(0, 0, 0);
   
}


.display-3{
    text-align: center;
    margin-top:50px;
    
}


.navbar.main {
  
   background-color:rgb(0, 0, 0);
    color: rgb(255, 255, 255);
    margin-top: 0px;
    border-style: none;
    border-radius: 0%;
    
    
}
.nav-pills{
 margin-top:2px;
text-align: center;
margin-top:5px;
margin-bottom: 0px;
}

#tab{
    color: white;    
}

#tab:hover {
    background-color: rgb(63, 60, 60);
}



.frosted-glass {
    
    width:10%;
    height:auto;
    background: inherit;
    position: relative;
    z-index: 1;
    overflow: hidden;
    margin: 30px,30px,30px,30px;
    padding: 2rem;
    box-sizing: border-box; 
  }
  
  .frosted-glass::before {
    width:auto;
    height:auto;
    content: "";
    position: absolute;
    z-index: -1;
    top: 0; right: 0; bottom: 0; left: 0;
    background: inherit;
    box-shadow: inset 0 0 3000px rgba(255,255,255,.5);
    filter: blur(5px);

  }
  #product-panel{
    width:70%;
    height: 400px;
    text-align:left;
    float:left;   
}

#contact-details{
    width:30%;
    height: 330px;
    text-align:left;
    margin-left: auto;
    margin-bottom: 100px;
    float:left;
    
  }

  #details{
    text-align: center;
}
enter code here

`<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" media="screen" href="fonts\css\font-awesome.min.css">
    <link rel="stylesheet" type="text/css" media="screen" href="css\KAD-css.css">
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <title>Website</title>
</head>

<body class="background">
  
  
        <div class="jumbotron jumbotron-fluid frosted-glass" id="header-frosted" >
                <div class="container img-responsive">
                  
                  <h1 class="display-3">Random Title</h1>
                  
                </div>
              </div>

              <nav class="navbar navbar-expand-lg navbar-dark  navbar-default main" >
                  <div class="container-fluid">
                    <div class="navbar-header">
                      <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span> 
                      </button>
                      <a class="navbar-brand" href="#"id="tab">Random Title</a>
                    </div>
                    <div class="collapse navbar-collapse text-centre" id="myNavbar">
                      <ul class="nav  nav-pills center-pills">
                          <li class="nav-item ">

  
                              <a class="nav-link" href="#" id="tab"> Random1
                               
                              </a>
                            </li>
                            <li class="nav-item ">

  
                                <a class="nav-link" href="#"id="tab"> Random2
                                 
                                </a>
                              </li>
                              <li class="nav-item">

  
                                  <a class="nav-link" href="#"id="tab"> Random3
    
                                  </a>
                                </li>
                      </ul>
                      <ul class="nav navbar-nav navbar-right">
                        
                      </ul>
                    </div>
                  </div>
                </nav>'


 <!--Product Panel-->
<div class="frosted-glass" id="product-panel">
This is the div in question.


  
</div>

<div class="frosted-glass" id="contact-details">
   <h3 id="details">Contact Details</h3>
 <p><strong>Name:</strong>John Doe</p>
 <p><strong>Phone Number:</strong> 000000000</p>
 <h3>Address:</h3>
 <strong><p>Random Title.</p>
 <p>PO Box 000</p>
 <p>Random Town, Random Country</p>
 <p>000</p>
 </strong>
</div>
</body>
</html>