并排显示图像(display images side by side)
我试图并排显示2个箭头链接,但我得到一些CSS错误。
我的html代码如下:
<div> <a href="javascript:void(0);" id="move_down"> <span class="down_arrow"> </span> </a> <a href="javascript:void(0);" id="move_up"> <span class="up_arrow"> </span></a> </div>
CSS:
.down_arrow{ display:block; background: url(../images/down_arrow.png) no-repeat left center; } .up_arrow{ display:block; background: url(../images/up_arrow.png) no-repeat left center; }
目前,图像一个在另一个下方显示。 我希望然后并排显示。 但是如果我删除
display:block;
在css中,图像显示不正确。我也尝试删除display:block并将float:left放在两个类中,但仍然无效。
如果有人能为我提供解决方案,我将不胜感激。
非常感谢。
I am trying to display 2 arrow links side by side but am getting some css errors.
My html code is below:
<div> <a href="javascript:void(0);" id="move_down"> <span class="down_arrow"> </span> </a> <a href="javascript:void(0);" id="move_up"> <span class="up_arrow"> </span></a> </div>
CSS:
.down_arrow{ display:block; background: url(../images/down_arrow.png) no-repeat left center; } .up_arrow{ display:block; background: url(../images/up_arrow.png) no-repeat left center; }
Currently, the images are displayed one below another. I want then to be displayed side by side. However if i remove the
display:block;
in the css, the image is not displayed properly.I also tried removing the display:block and put float:left for both classes but still not working.
I would be grateful if someone could provide me with a solution.
Many many thanks.
原文:https://stackoverflow.com/questions/6253466
最满意答案
此方法以递归方式将样式应用于MenuItem及其所有子项及其子项:
<MenuItem Header="Main Menu Item"> <MenuItem Header="Unaffected Sibling" /> <MenuItem Header="Foo"> <MenuItem.Resources> <Style TargetType="MenuItem"> <Setter Property="MenuItem.Header" Value="{Binding InAppName}" /> <Setter Property="IsCheckable" Value="True" /> <Setter Property="IsChecked" Value="{Binding IsSomeRandomBoolProperty}" /> <Setter Property="Background" Value="YellowGreen" /> <Setter Property="FontWeight" Value="Bold" /> <Setter Property="Foreground" Value="Red" /> </Style> </MenuItem.Resources> <MenuItem Header="Bar" /> <MenuItem Header="I Am Damo Suzuki"> <MenuItem Header="Blah blah blah"> <MenuItem Header="Amon Duul II" /> </MenuItem> </MenuItem> </MenuItem> </MenuItem>
This method applies a style to a MenuItem and all of its children, and their children, recursively:
<MenuItem Header="Main Menu Item"> <MenuItem Header="Unaffected Sibling" /> <MenuItem Header="Foo"> <MenuItem.Resources> <Style TargetType="MenuItem"> <Setter Property="MenuItem.Header" Value="{Binding InAppName}" /> <Setter Property="IsCheckable" Value="True" /> <Setter Property="IsChecked" Value="{Binding IsSomeRandomBoolProperty}" /> <Setter Property="Background" Value="YellowGreen" /> <Setter Property="FontWeight" Value="Bold" /> <Setter Property="Foreground" Value="Red" /> </Style> </MenuItem.Resources> <MenuItem Header="Bar" /> <MenuItem Header="I Am Damo Suzuki"> <MenuItem Header="Blah blah blah"> <MenuItem Header="Amon Duul II" /> </MenuItem> </MenuItem> </MenuItem> </MenuItem>
相关问答
更多-
这可能不是您要查找的内容,但是您可以为MenuItem类编写一个扩展,使您可以使用类似于RadioButton类的GroupName属性的内容。 我稍微修改了这个方便的示例,用于类似地扩展ToggleButton控件,并针对您的情况稍微修改了一下,并提出了这个问题: using System; using System.Collections.Generic; using System.Windows; using System.Windows.Controls; using System.Windows. ...
-
一个可能的选择是使用QActionGroup并激活专有属性 import sys from PyQt5.QtWidgets import * class MainWindow(QMainWindow): def __init__(self, *args, **kwargs): QMainWindow.__init__(self, *args, **kwargs) menu = self.menuBar() paymentType = QMenu('P ...
-
如何动态添加MenuItems(带标题)到WPF菜单(How to dynamically add MenuItems (with a header) to a WPF menu)[2023-10-09]
我承认,我没有深入研究你的例子,或许我应该这样做,但是每当我看到在搜索视觉树的代码隐藏时,我认为可以在视图模型中更明确地处理它? 在我看来,在这种情况下,您可以想出一个非常简单的视图模型 - 例如公开Text , Image , Command和Children属性的对象 - 然后创建一个简单的数据模板,将其呈现为MenuItem 。 然后,任何需要更改菜单内容的操作都可以操作此模型。 编辑: 仔细查看了你的详细信息以及你在博客文章中链接到的两个示例后,我的头靠在桌子上。 这两位开发人员似乎都错误地认为,在 ... -
Holo中的多选列表似乎有两种UI模式(在ActionMode的上下文中):使用复选框或突出显示。 如果您只需要突出显示,您可以使用这个更简单的方法: 让您的列表项目布局使用根类像这样的一个类: public class CheckableRelativeLayout extends RelativeLayout implements Checkable { private static final int[] STATE_CHECKABLE = {R.attr.state_pressed}; boolea ...
-
Android可选菜单项(Android Checkable Menu Item)[2022-04-22]
布局看起来正确 但您必须在代码中检查并取消选中菜单项。 从文档 : 当选择可选项目时,系统将调用相应的项目选择的回调方法(例如onOptionsItemSelected() )。 在这里,您必须设置复选框的状态,因为复选框或单选按钮不会自动更改其状态。 您可以使用isChecked()查询项目的当前状态(如用户选择之前的状态isChecked() ,然后使用setChecked()设置检查状态。 Layout looks right. But you must check and uncheck menu ... -
我在这里找到了答案。 我的XAML首先看起来像这样:最后,在默认库中查看了一天以上后,我通过以下调整在我的应用程序中工作: 布局文件
将菜单项绑定到一个集合,使它们可以检查并设置样式(Bind Menuitems to a collection, make them checkable and style the)[2022-09-09]
此方法以递归方式将样式应用于MenuItem及其所有子项及其子项: