简体   繁体   English

2个内联div,第2个与第一个不匹配

[英]2 inline div's, 2nd one won't fit in line with the 1st one

I'm trying to get the first div, '#grp1', left-aligned and inline with the second div, '#grp2'. 我正在尝试将第一个div'#grp1'左对齐并与第二个div'#grp2'内联。 Both divs have 2 input elements in them which are vertically aligned within their divs. 两个div中都有2个输入元素,它们在其div中垂直对齐。

The issue is that the grp2 div isn't scaling its width to fit onto the same line. 问题是grp2 div的宽度没有按比例缩放以适合同一行。 I keep resetting its width, but the console element inspector shows it isn't reducing on the page. 我一直在重置其宽度,但控制台元素检查器显示页面上的宽度没有减少。 I've gotten them on the same line only by reducing the with of grp1. 我仅通过减少grp1的使用使它们处于同一行。 grp2 still wasn't changing. grp2仍然没有改变。 I'd like everything to be much more compact. 我希望所有内容都更加紧凑。

Thank you very much. 非常感谢你。 If you have a sec, I'd appreciate some detail as to why the grp2 div isn't scaling at all; 如果您有时间,我将对grp2 div为何根本不扩展的一些细节表示赞赏; I seem to keep getting stuck on markup issues. 我似乎总是在标记问题上陷入困境。

 legend{ color: RGB(25, 115, 115); } .label { float:left; width:60%; margin-top: 5px; font-weight:bold; color: RGB(25,90,90); font-size: 18; font-weight: 8; font-family: 'Open Sans Condensed', sans-serif; } .form-text{ color: RGB(100,100,100); font-size: 15; font-weight: 6; font-family: 'Open Sans Condensed', sans-serif; margin-top: 3px; } .grp1{ float: left; width: 40%; position: relative; } .grp2{ position: relative; margin-left: 45%; } select{ margin-bottom: 29px; } .err{ font-size: 15; font-style: italic; color: RGB(180,100,100); } 
 <div id="form-input"> <form id="form"> <fieldset> <legend class='form-text' style='font-size:20'>Hello World</legend> <div id='grp1' style='display:inline-block' class='grp1'> <label for='subject'style='display:block' class='label'> Choose your subject.<br> <input type="text" id="subject" name='subject' style="display:block" class='form-text'><br> </label> <label for='mode' style='display:block' class='label'> Select your search mode.<br> <select name="mode" form="form-input" id="mode" class='form-text' onchange="buttonHandler(this)"> <option value="1">Search</option> <option value="2">Live</option> </select> </label> </div> <div id='grp2' style='display:inline-block' class='grp2'> <label for='startdate' style='display:block' id='startlabel' class='label'> Choose a start date for a search, up to one week ago: <br> <input type="text" id="startdate" value="" placeholder="day/month/2016" style="display:block" class='form-text'><br> <div name="error1" id="starterror" style="display:none" class='err'></div> </label> <label for='enddate' style='display:block' id='endlabel' class='label'> Choose an end date for your search: <br> <input type="text" id="enddate" style="display:block" class='form-text'><br> <div name="error2" id="enderror" style="display:none" class='err'></div> </label> </div> </fieldset> </form> </div> 

Since you have made it relative, no need to give 45% margin. 由于您已将其设为相对,因此无需提供45%的保证金。 Just remove it, and it will work. 只需将其删除,它将起作用。

 legend{ color: RGB(25, 115, 115); } .label { float:left; width:60%; margin-top: 5px; font-weight:bold; color: RGB(25,90,90); font-size: 18; font-weight: 8; font-family: 'Open Sans Condensed', sans-serif; } .form-text{ color: RGB(100,100,100); font-size: 15; font-weight: 6; font-family: 'Open Sans Condensed', sans-serif; margin-top: 3px; } .grp1{ float: left; width: 40%; position: relative; } .grp2{ position: relative; } select{ margin-bottom: 29px; } .err{ font-size: 15; font-style: italic; color: RGB(180,100,100); } 
 <div id="form-input"> <form id="form"> <fieldset> <legend class='form-text' style='font-size:20'>Hello World</legend> <div id='grp1' style='display:inline-block' class='grp1'> <label for='subject'style='display:block' class='label'> Choose your subject.<br> <input type="text" id="subject" name='subject' style="display:block" class='form-text'><br> </label> <label for='mode' style='display:block' class='label'> Select your search mode.<br> <select name="mode" form="form-input" id="mode" class='form-text' onchange="buttonHandler(this)"> <option value="1">Search</option> <option value="2">Live</option> </select> </label> </div> <div id='grp2' style='display:inline-block' class='grp2'> <label for='startdate' style='display:block' id='startlabel' class='label'> Choose a start date for a search, up to one week ago: <br> <input type="text" id="startdate" value="" placeholder="day/month/2016" style="display:block" class='form-text'><br> <div name="error1" id="starterror" style="display:none" class='err'></div> </label> <label for='enddate' style='display:block' id='endlabel' class='label'> Choose an end date for your search: <br> <input type="text" id="enddate" style="display:block" class='form-text'><br> <div name="error2" id="enderror" style="display:none" class='err'></div> </label> </div> </fieldset> </form> </div> 

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 对于所有屏幕尺寸,在一个导航中将1st 2nd设置为低于1st - Set 2nd div below 1st in one nav for all screen size 显示第一个 div 并隐藏其余部分,然后几秒钟后通过隐藏其余部分(包括第一个 div)来显示第二个 div - display one 1st div and hide rest then after few seconds display 2nd div by hiding rest of them including 1st div 响应时将第一个 Div 移动到第二个 Div - Move 1st Div to 2nd Div on responsive 当第二个中的第一个可观测值需要时,如何在angular2中链接两个可观测的对象 - How to chain two observables in angular2, when value of 1st observable need in 2nd one 如何在第一天之前设置我的第二个日期选择器? - How do I set my 2nd datepicker one day ahead of the 1st? 在第一个结束后在后台进行第二个 API 调用 - Make 2nd API call in the background after 1st one ends in an observable 我第一页的照片没有传递到第二页 - My photo from my 1st page is not passing down to my 2nd one jQuery一种衬板,用于查找和突出显示第一个单元格为gte第二个单元格的行 - jQuery one liner for finding and highlighting rows where contents of 1st cell is gte 2nd cell 使用ajax和PHP基于第一个选择框填充第二个选择框 - populating a 2nd select box based off the 1st one using ajax and PHP 如何通过使用Javascript或JQuery对第一个数组进行排序来对第二个数组进行排序? - How to sort 2nd array by sorting the 1st one using Javascript or JQuery?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM