2017-02-13 103 views
0

我正在使用jquery日期選擇器,我添加了日期選擇器到我的jsp頁面,並且我想要將其向左移動,但它不工作..
在我的jsp頁面中我有保證金左css不工作

<div id="datepicker" class="datepicker"> 
     <script> 
     $("#datepicker").datepicker(); 
     </script> 
     </div> 

,並在我的CSS文件,我有

.datepicker{ 

     margin-top:20px; 
     margin-left:600px; 
     position: fixed; 

} 

,但該元素總是在左上角corner..Does有人對這個解決辦法嗎?我一直用的margin-top和margin-左右,當我想要定位元素,它總是工作..提前感謝!

+1

這是因爲你有'position:fixed;'set所以它會把它放在左上角,因爲這些是'top'和'left'的默認值(0)。如果你要這樣定位,那麼將'top'和'left'設置爲你想要的值。 – zgood

+0

我把'top:20px'和'left:600px',但它是一樣的。據我所知,margin-left和margin-top將該元素向左和向下移動以獲得該像素數量,並且這就是我所需要的..我不知道什麼是頂部和左邊,邊緣頂部和邊緣左邊之間的區別.. – slomilll

回答

0

我遇到麻煩日期選擇器功能上codepen運行,但CSS格式部分工作得很好:https://codepen.io/anon/pen/OWdXKL

<style> 
    .datepicker{ 
     margin-top:20px; 
     margin-left:600px; 
     position: fixed; 
}; 
</style> 

<div id="datepicker" class="datepicker">this div is 600 px from the left; 20 px from the top</div> 

<script> 
    $("#datepicker").datepicker(); 
</script> 

我的猜測是,有一些別的地方在你的樣式表正在覆蓋您提供的剪輯中定義的邊距。

+0

它現在的作品,當我清理項目在日食和抹去歷史......無論如何感謝! – slomilll