简体   繁体   English

如何在同一行中对齐span和html下拉列表?

[英]How to align the span and html dropdown in same line?

I designed the UI like the below. 我设计的用户界面如下所示。

<div class="rightbadger">
    <span id="filterRecords">
        Number of Results Per Page
        <%:Html.DropDownList(
            "filterByPageNumber", 
            Model.ResultPerPage,
            null,
            new { onchange = "GetResultsPerPage()" }
        )
        %>
    </span>
</div>

CSS: CSS:

.rightbadger { margin-left: 600px;}

But span and dropdown list are not aligned properly in same line.in some browsers are looking good but some of the browsers showing like the below. 但是跨度和下拉列表在同一行中排列不正确。在某些浏览器中看起来不错,但在某些浏览器中显示如下所示。 以下是图片的屏幕截图

Just put the CSS 只需把CSS

.filterRecords select{
    display:block;
}

If you want to align them vertically you probably should put the text into a separate element, like so: 如果要垂直对齐它们,则可能应将文本放在单独的元素中,如下所示:

<div class="rightbadger">
    <div id="filterRecords">
        <span>Number of Results Per Page</span>
        <%:Html.DropDownList(
            "filterByPageNumber", 
            Model.ResultPerPage,
            null,
            new { onchange = "GetResultsPerPage()" }
        )
        %>
    </div>
</div>

Then vertical align the 2 element as you want them to be: 然后垂直对齐2元素,如您所愿:

#filterRecords span,
#filterRecords select{ /*or just '#filterRecords *' */
    vertical-align: bottom; /*or middle; or top; */
}

You must to set for span and dropdown: 您必须设置跨度和下拉列表:

float:left;
width:300px;
display:block;

如何使用自定义 html 下拉菜单<div><span></span></div><div id="text_translate"><p>我正在尝试创建一个定价表来展示基于购买条款(每月、每年、三年一次)的服务定价。</p><p> 从下拉列表中选择一个选项会使用 javascript 更改链接属性,这正是我想要的,但是,下拉选项的实际样式似乎相当困难。</p><p> 试图在没有任何可行解决方案的情况下连续数小时实现这一目标。</p><p> 附件是我想要实现的目标的图像。</p><p> <a href="https://i.stack.imgur.com/afsZC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/afsZC.png" alt="在此处输入图像描述"></a></p><p> 有谁知道我做错了什么?</p><pre> &lt;div class="ive-hpbox"&gt; &lt;h3&gt;Simple Price Box&lt;/h3&gt; &lt;div class="dropdown-plans"&gt; &lt;select id="dynamic_select"&gt; &lt;option value="cart.php?a=add&amp;pid=1548&amp;billingcycle=monthly"&gt; &lt;h3&gt;Monthly&lt;/h3&gt; &lt;span class="hp-price"&gt;$12.00/mo&lt;/span&gt; &lt;/option&gt; &lt;option value="cart.php?a=add&amp;pid=1548&amp;billingcycle=annually" selected&gt; &lt;h3&gt;SAVE 50%&lt;/h3&gt; &lt;span class="hp-disc-price"&gt;1 Year at &lt;strike&gt;$144.00/mo&lt;/strike&gt;&lt;/span&gt; &lt;span class="hp-price"&gt;$72.00/mo&lt;/span&gt; &lt;/option&gt; &lt;option value="cart.php?a=add&amp;pid=1548&amp;billingcycle=triennially"&gt; &lt;h3&gt;SAVE 70%&lt;/h3&gt; &lt;span class="hp-disc-price"&gt;3 Year at &lt;strike&gt;$432.00/mo&lt;/strike&gt;&lt;/span&gt; &lt;span class="hp-price"&gt;$129.60/mo&lt;/span&gt; &lt;/option&gt; &lt;/select&gt; &lt;/div&gt; &lt;p class="hecont act"&gt;Attractive selling introduction to the plan followed by an unordered list. &lt;strong&gt;Save huge&lt;/strong&gt; with a pro-plan.&lt;/p&gt; &lt;ul&gt; &lt;li&gt;&lt;i class="fa fa-check"&gt;&lt;/i&gt; Disk Storage Space&lt;/li&gt; &lt;li&gt;&lt;i class="fa fa-check"&gt;&lt;/i&gt; Accounts&lt;/li&gt; &lt;li&gt;&lt;i class="fa fa-check"&gt;&lt;/i&gt; Antivirus Filtering&lt;/li&gt; &lt;li&gt;&lt;i class="fa fa-check"&gt;&lt;/i&gt; Anti-spam Filtering&lt;/li&gt; &lt;li&gt;&lt;i class="fa fa-check"&gt;&lt;/i&gt; Auto Responders&lt;/li&gt; &lt;li&gt;&lt;i class="fa fa-check"&gt;&lt;/i&gt; IMAP / POP3 Protocols&lt;/li&gt; &lt;li&gt;&lt;i class="fa fa-check"&gt;&lt;/i&gt; Control Panel&lt;/li&gt; &lt;/ul&gt; &lt;a class="but_small1" href="#features"&gt;View Features&lt;/a&gt; &lt;a id="order-btn"&gt; Order now &lt;/a&gt; &lt;/div&gt; document.getElementById("dynamic_select").onclick = function() { document.getElementById("order-btn"):href = "https.//example.com/"+this;value+"/". }:ive-hpbox{ width;350px: border;1px solid #a1a1a1: border-radius.;25em: padding;10px: text-align;center. }:ive-hpbox:hover{ box-shadow,0 0 10px rgba(0,0,0.;15). } #dynamic_select option:hp-saving { font-size;26px: } #dynamic_select { border; 1px solid #a1a1a1: padding;10px: text-align;center: background;#fff: width;90%. }:ive-hpbox ul{ display;block: text-align;left; }</pre><p> <a href="https://jsfiddle.net/6rsgnmdy/52/" rel="nofollow noreferrer">https://jsfiddle.net/6rsgnmdy/52/</a></p></div> - How to customize an html dropdown menu using <div><span>

暂无
暂无

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

相关问题 如何将高图甜甜圈图中心的HTML跨度与响应式设计对齐? - How to align HTML span at center of highchart donut graph with responsive design? HTML 对齐下拉元素 - HTML align dropdown elements 高图-如何在同一条线上对齐两个图表 - Highcharts - how to align two charts on a same line 如何使用自定义 html 下拉菜单<div><span></span></div><div id="text_translate"><p>我正在尝试创建一个定价表来展示基于购买条款(每月、每年、三年一次)的服务定价。</p><p> 从下拉列表中选择一个选项会使用 javascript 更改链接属性,这正是我想要的,但是,下拉选项的实际样式似乎相当困难。</p><p> 试图在没有任何可行解决方案的情况下连续数小时实现这一目标。</p><p> 附件是我想要实现的目标的图像。</p><p> <a href="https://i.stack.imgur.com/afsZC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/afsZC.png" alt="在此处输入图像描述"></a></p><p> 有谁知道我做错了什么?</p><pre> &lt;div class="ive-hpbox"&gt; &lt;h3&gt;Simple Price Box&lt;/h3&gt; &lt;div class="dropdown-plans"&gt; &lt;select id="dynamic_select"&gt; &lt;option value="cart.php?a=add&amp;pid=1548&amp;billingcycle=monthly"&gt; &lt;h3&gt;Monthly&lt;/h3&gt; &lt;span class="hp-price"&gt;$12.00/mo&lt;/span&gt; &lt;/option&gt; &lt;option value="cart.php?a=add&amp;pid=1548&amp;billingcycle=annually" selected&gt; &lt;h3&gt;SAVE 50%&lt;/h3&gt; &lt;span class="hp-disc-price"&gt;1 Year at &lt;strike&gt;$144.00/mo&lt;/strike&gt;&lt;/span&gt; &lt;span class="hp-price"&gt;$72.00/mo&lt;/span&gt; &lt;/option&gt; &lt;option value="cart.php?a=add&amp;pid=1548&amp;billingcycle=triennially"&gt; &lt;h3&gt;SAVE 70%&lt;/h3&gt; &lt;span class="hp-disc-price"&gt;3 Year at &lt;strike&gt;$432.00/mo&lt;/strike&gt;&lt;/span&gt; &lt;span class="hp-price"&gt;$129.60/mo&lt;/span&gt; &lt;/option&gt; &lt;/select&gt; &lt;/div&gt; &lt;p class="hecont act"&gt;Attractive selling introduction to the plan followed by an unordered list. &lt;strong&gt;Save huge&lt;/strong&gt; with a pro-plan.&lt;/p&gt; &lt;ul&gt; &lt;li&gt;&lt;i class="fa fa-check"&gt;&lt;/i&gt; Disk Storage Space&lt;/li&gt; &lt;li&gt;&lt;i class="fa fa-check"&gt;&lt;/i&gt; Accounts&lt;/li&gt; &lt;li&gt;&lt;i class="fa fa-check"&gt;&lt;/i&gt; Antivirus Filtering&lt;/li&gt; &lt;li&gt;&lt;i class="fa fa-check"&gt;&lt;/i&gt; Anti-spam Filtering&lt;/li&gt; &lt;li&gt;&lt;i class="fa fa-check"&gt;&lt;/i&gt; Auto Responders&lt;/li&gt; &lt;li&gt;&lt;i class="fa fa-check"&gt;&lt;/i&gt; IMAP / POP3 Protocols&lt;/li&gt; &lt;li&gt;&lt;i class="fa fa-check"&gt;&lt;/i&gt; Control Panel&lt;/li&gt; &lt;/ul&gt; &lt;a class="but_small1" href="#features"&gt;View Features&lt;/a&gt; &lt;a id="order-btn"&gt; Order now &lt;/a&gt; &lt;/div&gt; document.getElementById("dynamic_select").onclick = function() { document.getElementById("order-btn"):href = "https.//example.com/"+this;value+"/". }:ive-hpbox{ width;350px: border;1px solid #a1a1a1: border-radius.;25em: padding;10px: text-align;center. }:ive-hpbox:hover{ box-shadow,0 0 10px rgba(0,0,0.;15). } #dynamic_select option:hp-saving { font-size;26px: } #dynamic_select { border; 1px solid #a1a1a1: padding;10px: text-align;center: background;#fff: width;90%. }:ive-hpbox ul{ display;block: text-align;left; }</pre><p> <a href="https://jsfiddle.net/6rsgnmdy/52/" rel="nofollow noreferrer">https://jsfiddle.net/6rsgnmdy/52/</a></p></div> - How to customize an html dropdown menu using <div><span> 将div对准同一行 - align the div in same line 如何使提交按钮在 html 中“打印”内容,并在与 a 相同的行中输入宽度为 100% 的文本<span>,</span><p> <span>, 或者</span><div> <span>?</span> - How do I make submit buttons 'print' things in html and make a text input with 100% width in the same line as a <span>, <p>, or <div>? 如何对齐列表下拉列表 - how to align list dropdown HTML-如何插入 <span></span> 标记到每行 <pre></pre> 块没有硬编码? - HTML - How do I insert a <span></span> tag into each line of a <pre></pre> block without hard coding? html表跨度,如果数据相同 - html table span if the data is same 如何将标签和输入对齐在右侧的同一行? - How do I align Label and Input on the same line to the right?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM