Javascript 如何使用CSS水平对齐div?
我的代码有问题。我正在为我的项目创建一个导航菜单,但我不太擅长CSS。Javascript 如何使用CSS水平对齐div?,javascript,jquery,html,css,Javascript,Jquery,Html,Css,我的代码有问题。我正在为我的项目创建一个导航菜单,但我不太擅长CSS。 我有两个div标签。每个div标签都是一个下拉式手风琴。我想要的是把第二个div放在第一个div旁边。这是我的一些代码 HTML jQuery $(document).ready(function($){ $('#accordion-1').dcAccordion({ eventType: 'click', autoClose: false, saveState: tr
我有两个div标签。每个div标签都是一个下拉式手风琴。我想要的是把第二个div放在第一个div旁边。这是我的一些代码 HTML jQuery
$(document).ready(function($){
$('#accordion-1').dcAccordion({
eventType: 'click',
autoClose: false,
saveState: true,
disableLink: true,
speed: 'fast',
classActive: 'test',
showCount: false
});
$('#accordion-2').dcAccordion({
eventType: 'click',
autoClose: true,
saveState: true,
disableLink: true,
speed: 'slow',
showCount: true,
autoExpand: true,
cookie : 'dcjq-accordion-1',
classExpand : 'dcjq-current-parent'
});
});
这是一架手风琴。这是我的推荐信:这是我的菜单:
像这样吗 像这样 像这样 像这样
只需将此添加到css上的.grey.accordio
width:50%;
float:left;
只需将此添加到css上的.grey.accordio
width:50%;
float:left;
只需将此添加到css上的.grey.accordio
width:50%;
float:left;
只需将此添加到css上的.grey.accordio
width:50%;
float:left;
试试这个
<div id=Main_div">
<div id="left_div">div 1</div>
<div id="right_div">div 2</div>
</div>
since left_div is 50%, assume you have a menu which needed 20% of 50% width, then place a ID to the navigation then add css to it like
#nav_css
{
width:60%; //which will be 60% of 50%
margin:5%; // margin will be present for top,bottom,left,right
border:1px solid teal; //which helps you in aligning its space
}
以及导航宽度
试试这个
<div id=Main_div">
<div id="left_div">div 1</div>
<div id="right_div">div 2</div>
</div>
since left_div is 50%, assume you have a menu which needed 20% of 50% width, then place a ID to the navigation then add css to it like
#nav_css
{
width:60%; //which will be 60% of 50%
margin:5%; // margin will be present for top,bottom,left,right
border:1px solid teal; //which helps you in aligning its space
}
哪一部分你不懂???试试这个
<div id=Main_div">
<div id="left_div">div 1</div>
<div id="right_div">div 2</div>
</div>
since left_div is 50%, assume you have a menu which needed 20% of 50% width, then place a ID to the navigation then add css to it like
#nav_css
{
width:60%; //which will be 60% of 50%
margin:5%; // margin will be present for top,bottom,left,right
border:1px solid teal; //which helps you in aligning its space
}
以及导航宽度
试试这个
<div id=Main_div">
<div id="left_div">div 1</div>
<div id="right_div">div 2</div>
</div>
since left_div is 50%, assume you have a menu which needed 20% of 50% width, then place a ID to the navigation then add css to it like
#nav_css
{
width:60%; //which will be 60% of 50%
margin:5%; // margin will be present for top,bottom,left,right
border:1px solid teal; //which helps you in aligning its space
}
哪一部分你不懂???试试这个
<div id=Main_div">
<div id="left_div">div 1</div>
<div id="right_div">div 2</div>
</div>
since left_div is 50%, assume you have a menu which needed 20% of 50% width, then place a ID to the navigation then add css to it like
#nav_css
{
width:60%; //which will be 60% of 50%
margin:5%; // margin will be present for top,bottom,left,right
border:1px solid teal; //which helps you in aligning its space
}
以及导航宽度
试试这个
<div id=Main_div">
<div id="left_div">div 1</div>
<div id="right_div">div 2</div>
</div>
since left_div is 50%, assume you have a menu which needed 20% of 50% width, then place a ID to the navigation then add css to it like
#nav_css
{
width:60%; //which will be 60% of 50%
margin:5%; // margin will be present for top,bottom,left,right
border:1px solid teal; //which helps you in aligning its space
}
哪一部分你不懂???试试这个
<div id=Main_div">
<div id="left_div">div 1</div>
<div id="right_div">div 2</div>
</div>
since left_div is 50%, assume you have a menu which needed 20% of 50% width, then place a ID to the navigation then add css to it like
#nav_css
{
width:60%; //which will be 60% of 50%
margin:5%; // margin will be present for top,bottom,left,right
border:1px solid teal; //which helps you in aligning its space
}
以及导航宽度
试试这个
<div id=Main_div">
<div id="left_div">div 1</div>
<div id="right_div">div 2</div>
</div>
since left_div is 50%, assume you have a menu which needed 20% of 50% width, then place a ID to the navigation then add css to it like
#nav_css
{
width:60%; //which will be 60% of 50%
margin:5%; // margin will be present for top,bottom,left,right
border:1px solid teal; //which helps you in aligning its space
}
哪一部分你不懂???像这样的?是的..您更改了什么部分?为您的班级设置
手风琴宽度:50%
和浮动:左
,谢谢。很抱歉,我对CSS知之甚少。:)float:left&display:inline块将帮助您,它将保存元素的宽度像这样吗?是的..您更改了什么部分?为您的班级设置手风琴宽度:50%
和浮动:左
,谢谢。很抱歉,我对CSS知之甚少。:)float:left&display:inline块将帮助您,它将保存元素的宽度像这样吗?是的..您更改了什么部分?为您的班级设置手风琴宽度:50%
和浮动:左
,谢谢。很抱歉,我对CSS知之甚少。:)float:left&display:inline块将帮助您,它将保存元素的宽度像这样吗?是的..您更改了什么部分?为您的班级设置手风琴宽度:50%
和浮动:左
,谢谢。很抱歉,我对CSS知之甚少。:)float:left&display:inline块将帮助您,它将保存当前工作的元素的宽度。但是你能帮我吗?导航菜单是50%的。如何压缩导航的宽度?删除该宽度和float,然后尝试添加这个div.grey{float:left;}这就是你的意思吗?好的,它正在工作。但还有一个问题,我希望你能帮助我。我有这个导航。但是我怎样才能重叠菜单呢?下面是我的照片库。我将更新我的小提琴。重叠菜单是什么意思?因为在我的代码中,标题菜单是categories1和categories2。如果你点击这些类别,它将执行一个手风琴,这是子菜单。如何将子菜单div与下面的另一个div重叠?是的,它正在工作。但是你能帮我吗?导航菜单是50%的。如何压缩导航的宽度?删除该宽度和float,然后尝试添加这个div.grey{float:left;}这就是你的意思吗?好的,它正在工作。但还有一个问题,我希望你能帮助我。我有这个导航。但是我怎样才能重叠菜单呢?下面是我的照片库。我将更新我的小提琴。重叠菜单是什么意思?因为在我的代码中,标题菜单是categories1和categories2。如果你点击这些类别,它将执行一个手风琴,这是子菜单。如何将子菜单div与下面的另一个div重叠?是的,它正在工作。但是你能帮我吗?导航菜单是50%的。如何压缩导航的宽度?删除该宽度和float,然后尝试添加这个div.grey{float:left;}这就是你的意思吗?好的,它正在工作。但还有一个问题,我希望你能帮助我。我有这个导航。但是我怎样才能重叠菜单呢?下面是我的照片库。我将更新我的小提琴。重叠菜单是什么意思?因为在我的代码中,标题菜单是categories1和categories2。如果你点击这些类别,它将执行一个手风琴,这是子菜单。如何将子菜单div与下面的另一个div重叠?是的,它正在工作。但是你能帮我吗?导航菜单是50%的。如何压缩导航的宽度?删除该宽度和float,然后尝试添加这个div.grey{float:left;}这就是你的意思吗?好的,它正在工作。但还有一个问题,我希望你能帮助我。我有这个导航。但是我怎样才能重叠菜单呢?下面是我的照片库。我将更新我的小提琴。重叠菜单是什么意思?因为在我的代码中,标题菜单是categories1和categories2。如果你点击这些类别,它将执行一个手风琴,这是子菜单。如何将子菜单div与下面的另一个div重叠?您可以添加此:显示:内联块我应该将其放置在哪里?您可以添加此:显示:内联块我应该将其放置在哪里?您可以添加此:显示:内联块我应该将其放置在哪里?您可以添加此:显示:内联块我应该将其放置在哪里?好的,我会的试试看……)我做了你的代码,但我不明白你说的最后一部分(好的,我试试看。)我做了你的代码,但我不明白你说的最后一部分(好的,我试试看。)我做了你的代码,但我不明白你说的最后一部分(好的,我试试看。)我做了你的代码,但我不明白你说的最后一部分(