将2个图像标记彼此相邻放置

时间:2021-03-24 14:01:41

I´ve got the following images in a div:

我在div中得到了以下图像:

 <div id="desc_attach_scroll">
    <img class="A" src="img/up.png" />
    <img class="B" src="img/down.png" />
 </div>

At the moment class B image is sitting vertically under class A image. I want to move B to the righthand side of A. I tried to float them but it didn´t work. Any suggestions?

目前,B类图像垂直位于A类图像下。我想将B移到A的右侧。我试图漂浮它们但它没有用。有什么建议么?

3 个解决方案

#1


2  

Floats should work just fine.... See this Fiddle

花车应该工作得很好....看到这个小提琴

Note.. if you use uppercase characters for class assignments, you must match the case for the stylesheet in most cases.

注意..如果对类分配使用大写字符,则在大多数情况下必须匹配样式表的大小写。

#2


1  

If the width of Image A and Image B combined are too wide to fit into the width provided by the desc_attach_scroll container, no amount of flow-based css (in particular, floats) will get them to appear side by side. You can try using absolute positioning to get them next to each other, but that could cause you some serious headaches if the image widths ever change.

如果组合的图像A和图像B的宽度太宽而不适合desc_attach_scroll容器提供的宽度,则任何数量的基于流的css(特别是浮点数)都不会使它们并排显示。您可以尝试使用绝对定位使它们彼此相邻,但如果图像宽度发生变化,这可能会导致严重的问题。

If Image A and Image B are not too wide for the space provided by the container, they should automatically flow next to each other without any special css rules applied.

如果图像A和图像B对于容器提供的空间不是太宽,它们应该自动地彼此相邻地流动,而不应用任何特殊的css规则。

#3


0  

You need to give width in order for float to work;

你需要给宽度以便浮动工作;

DEMO

DEMO

#1


2  

Floats should work just fine.... See this Fiddle

花车应该工作得很好....看到这个小提琴

Note.. if you use uppercase characters for class assignments, you must match the case for the stylesheet in most cases.

注意..如果对类分配使用大写字符,则在大多数情况下必须匹配样式表的大小写。

#2


1  

If the width of Image A and Image B combined are too wide to fit into the width provided by the desc_attach_scroll container, no amount of flow-based css (in particular, floats) will get them to appear side by side. You can try using absolute positioning to get them next to each other, but that could cause you some serious headaches if the image widths ever change.

如果组合的图像A和图像B的宽度太宽而不适合desc_attach_scroll容器提供的宽度,则任何数量的基于流的css(特别是浮点数)都不会使它们并排显示。您可以尝试使用绝对定位使它们彼此相邻,但如果图像宽度发生变化,这可能会导致严重的问题。

If Image A and Image B are not too wide for the space provided by the container, they should automatically flow next to each other without any special css rules applied.

如果图像A和图像B对于容器提供的空间不是太宽,它们应该自动地彼此相邻地流动,而不应用任何特殊的css规则。

#3


0  

You need to give width in order for float to work;

你需要给宽度以便浮动工作;

DEMO

DEMO