Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/466.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 确定元素是否缠绕在浮动元素上_Javascript_Html_Css_Word Wrap - Fatal编程技术网

Javascript 确定元素是否缠绕在浮动元素上

Javascript 确定元素是否缠绕在浮动元素上,javascript,html,css,word-wrap,Javascript,Html,Css,Word Wrap,我有一个图像,它是float:left 一个ul标签缠绕在该图像周围。它位于图像的右侧 ul中包含的自定义项目符号与浮动图像部分重叠 当ul稍微向右移动时,这是固定的 但是,要做到这一点,我需要确定ul是否围绕着这个图像 怎么做 更新1: 这段代码演示了这个问题。标准子弹也是如此,不仅仅是定制的 <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>B

我有一个图像,它是
float:left

一个
ul
标签缠绕在该图像周围。它位于图像的右侧

ul
中包含的自定义项目符号与浮动图像部分重叠

ul
稍微向右移动时,这是固定的

但是,要做到这一点,我需要确定
ul
是否围绕着这个图像

怎么做


更新1:

这段代码演示了这个问题。标准子弹也是如此,不仅仅是定制的

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
 <title>Bullets overlapping example</title>
</head>
<style type="text/css" media="screen">
 body {
  display: block;
  width: 400pt;
  margin: auto;
  border: solid thin gray;
 }
 img {
  float: left;
  width: 250pt;
 }
</style>
<body>
 <img src="http://www.hermann-uwe.de/files/images/blue_flower.preview_0.jpg" />
 <p>Bullets in a list below must be fixed someway, to prevent overlapping of float image</p>
 <ul>
  <li>Bullet of this list item overlaps left-hand-side image.</li>
  <li>This list item too</li>
  <li>And this ...</li>
 </ul>
 <div style="height: 6em;"></div>
 <p>This list should not be fixed, because it <b>does't wraps</b> the image</p>
 <ul>
  <li>One</li>
  <li>Two</li>
  <li>Three</li>
 </ul>
</body>
</html>

项目符号重叠示例
身体{
显示:块;
宽度:400磅;
保证金:自动;
边框:实心细灰色;
}
img{
浮动:左;
宽度:250磅;
}
下面列表中的项目符号必须以某种方式固定,以防止浮动图像重叠

  • 此列表项的项目符号与左侧图像重叠
  • 这个列表项也是
  • 而这个
此列表不应固定,因为它不会包装图像

  • 一个
  • 两个

您可以使用CSS选择器控制ULs内图像的特定行为:

ul img { ........ } /* This rule will apply only to images inside ULs */

在JavaScript中也可以,但这应该可以使用纯CSS进行分类。

您可以使用CSS选择器控制ULs内图像的特定行为:

ul img { ........ } /* This rule will apply only to images inside ULs */

这在JavaScript中也是可能的,但应该可以使用纯CSS进行分类。

不,这不是我的情况。我在CSS中有“列表样式图像”属性。这是无法控制的way@Anton啊,我明白了,如果
ul
包含图像,您需要解决它?不,我需要“确定,元素是否围绕着浮点元素”(参见文章标题:)。换句话说,我只需要将某些CSS样式应用于元素,而这些元素的布局被浮动元素改变了。@Anton啊。我认为如果没有非常复杂的jQuery,这是不可能做到的。但从声音上看,这不应该是必要的:可能是一个重叠的例子,这很可能在UL的CSSNo中是可以修复的,这不是我的情况。我在CSS中有“列表样式图像”属性。这是无法控制的way@Anton啊,我明白了,如果
ul
包含图像,您需要解决它?不,我需要“确定,元素是否围绕着浮点元素”(参见文章标题:)。换句话说,我只需要将某些CSS样式应用于元素,而这些元素的布局被浮动元素改变了。@Anton啊。我认为如果没有非常复杂的jQuery,这是不可能做到的。但从声音上看,这不应该是必要的:可能是一个重叠的例子,这很可能在UL的CSS中得到修复