简体   繁体   English

内联图像列表未与文本对齐,中断结构

[英]Inline image list not aligning with text, breaks structure

So I signed up here because I have something that drives me crazy. 所以我在这里报名,因为我有些东西让我发疯。 I am sure the answer is pretty straight and simple, but I just can see it... 我相信答案非常简单明了,但我只能看到它......

I want to make a small gallery for an article, showing screenshots from different video games. 我想为一篇文章制作一个小画廊,展示来自不同视频游戏的截图。 The problem: The list wont align correctly with the text within the content div . 问题:列表无法与内容div的文本正确对齐。 No matter what I do. 不管我做什么。 text-align: left just gets it to exactly this position, center and right work. text-align: left只是让它正好适合这个位置, centerright工作。 It is like it is aligning on the edge of a div , but there is none. 它就像是在div的边缘对齐,但没有。 Putting it within the needed <p> tags destroys the text like seen in the picture. 将它放在所需的<p>标签内会破坏图中所示的文本。 Keeping it out of the <p> tags keeps the text like it should be, but the list is exactly at the same place. 将它保留在<p>标签之外会使文本保持原样,但列表恰好位于同一位置。 I tried inline-block , inline , position: absolute etc, but nothing seems to work. 我尝试了inline-blockinlineposition: absolute等,但似乎没有任何效果。 I already tried searching the other div s for problems, but I just can't find anything. 我已经尝试过搜索其他div了解问题,但我找不到任何东西。 Here is a picture . 这是一张照片

This is the css: 这是css:

.gallerie {
    text-align: left;
    width: 100%;
}

.gallerie ul {
    list-style-type: none;
    margin: 0px;
    padding: 0px;
}

.gallerie li {
    display: inline;
    margin: 0px;
    padding: 0px;
}

Can't somehow show the HTML part here, but it's just a simple ul li list with images. 不能以某种方式在这里显示的HTML部分,但它只是一个简单的ul li名单与图像。 The whole thing is simple, but something just doesn't. 整件事情很简单,但事情并非如此。

Thanks in advance! 提前致谢!

Edit: 编辑:

So as I can't get the thing with the code right, here is the direct linkt to the page with that problem: Link to the Problem 因为我无法正确使用代码,所以这是与该问题的页面的直接链接链接到问题

I hope this is allowed here. 我希望这是允许的。 Thank you to the admin for editing, I am new here, and really not used to it. 感谢管理员的编辑,我是新来的,真的不习惯。 Thank you very much. 非常感谢你。

So guys, in short: 所以,简而言之:

wanted to add the pictures here, can't post more than two links 想在这里添加图片,不能发布两个以上的链接

Edit: Funny thing, it works when I put the ul li outside of the article tag. 编辑:有趣的是,当我把ul li放在文章标签之外时,它会起作用。 So I would have a workaround. 所以我会有一个解决方法。

Edit: The problem seems to be within the article tag. 编辑:问题似乎在文章标签内。 I have both, right and left margin in there. 我有两个左右边距。 But when I make it to margin 0px, the whole text moves left (thats why I have a margin of 20px there). 但当我将其设置为0px边距时,整个文本向左移动(这就是为什么我的边距为20px)。 I guess the problem will be a second unneeded margin. 我想这个问题将是第二个不必要的边际。

Edit: I fixed this by taking away the margin-left: 20px; 编辑:我通过取走边距左边修正了这个:20px; out of the article tag, and added the value to the p tag for that class instead. 超出了文章标记,并将值添加到该类的p标记中。 Works. 作品。 I don't really know what the error was, but it seems fine now. 我真的不知道错误是什么,但现在看起来很好。 Thank you all for your help. 谢谢大家的帮助。

Last Edit: You can see the working example when you refresh the link to the site. 上次编辑:刷新指向站点的链接时,可以看到工作示例。 Thanks for your help. 谢谢你的帮助。

Your problem is css padding 你的问题是css padding

<ul> tags have default padding. <ul>标签具有默认填充。 If you set padding: 0; 如果设置padding: 0; then the spacing should disappear. 间距应该消失。

I would say set text-align: center; 我会说set text-align: center; and padding: 0; padding: 0; for the .gallerie class 对于.gallerie

Is this what you want? 这是你想要的吗?

图片1

Corresponding css for .gallerie 对应的.gallerie CSS

图2

Padding Example: 填充示例:

 .padded { padding: 10px; background: red; } p { background: yellow; } 
 <div class="padded"> <p>This is some text</p> </div> 

Looking at the link to the page where the issue lies. 查看问题所在页面的链接。 Just give the .gallerie class padding:0; 只需给出.galleriepadding:0; and a margin-left:15px; margin-left:15px; (to achieve uniform indentation). (实现均匀压痕)。

It appears from the page that you may be attempting to wrap the <ul> in a <p> , which is not valid HTML. 从页面看来,您可能正在尝试将<ul>包装在<p> ,这是无效的HTML。

尝试将padding-left: 20px添加到<ul>并将文本包装在<p>

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM