html - 为什么 Chrome 会拉伸(stretch) 'align-items' 而不是像声明的那样将它们对齐到 'flex-end'?

标签 html css flexbox

我有这样的评论布局,其中每个评论(回复)的深度都比较薄:

ul { padding:0 } 

.col-1, .col-2, .col-3, .col-4, .col-5, .col-6, .col-7, .col-8, .col-9, .col-10, .col-11, .col-12, .col, .col-sm-1, .col-sm-2, .col-sm-3, .col-sm-4, .col-sm-5, .col-sm-6, .col-sm-7, .col-sm-8, .col-sm-9, .col-sm-10, .col-sm-11, .col-sm-12, .col-sm, .col-md-1, .col-md-2, .col-md-3, .col-md-4, .col-md-5, .col-md-6, .col-md-7, .col-md-8, .col-md-9, .col-md-10, .col-md-11, .col-md-12, .col-md, .col-lg-1, .col-lg-2, .col-lg-3, .col-lg-4, .col-lg-5, .col-lg-6, .col-lg-7, .col-lg-8, .col-lg-9, .col-lg-10, .col-lg-11, .col-lg-12, .col-lg, .col-xl-1, .col-xl-2, .col-xl-3, .col-xl-4, .col-xl-5, .col-xl-6, .col-xl-7, .col-xl-8, .col-xl-9, .col-xl-10, .col-xl-11, .col-xl-12, .col-xl {
    position: relative;
    width: 100%;
    min-height: 1px;
}

@media (min-width: 768px) {
    .col-md-10 {
        -webkit-box-flex: 0;
        -webkit-flex: 0 0 83.333333%;
        -ms-flex: 0 0 83.333333%;
        flex: 0 0 83.333333%;
        max-width: 83.333333%;
    }
    .col-md-11 {
        -webkit-box-flex: 0;
        -webkit-flex: 0 0 91.666667%;
        -ms-flex: 0 0 91.666667%;
        flex: 0 0 91.666667%;
        max-width: 91.666667%;
    }
    .col-md-12 {
        -webkit-box-flex: 0;
        -webkit-flex: 0 0 100%;
        -ms-flex: 0 0 100%;
        flex: 0 0 100%;
        max-width: 100%;
    }
}

/* Comments */

.comments-list {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
}

.comment {
}

.child-comments {
    display: flex;
    align-items: flex-end;
    flex-direction: column;
    height: auto;
}

.comment-wrapper {
    margin: 0 0 24px 0;
    padding: 0 0 24px 0;
    border-bottom: 1px solid rgba(0,0,0,0.2);
    display: inline-flex;
    flex-direction: row;
    max-width: 100%;#C69F73
}

.comment .avatar {
    margin-right: 24px;
    border-radius: 50%;
    object-fit: cover;
    position: relative;
    background-color: rgba(0,0,0,0.2);
}

.comment .info {
    display: flex;
    align-items: flex-start;
    flex-wrap: wrap;
    flex-direction: column;
}

.comment .comment-meta {
    margin: 0 0 12px 0;
}

.comment .comment-author {
    margin: 0 0 6px 0;
}

.comment .comment-author a {
    font-family: 'Simoncini Garamond Italic', sans-serif;
    font-weight: 600;
    font-size: 24px;
    margin: 0 0 4px 0;
}

.comment .comment-time {
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 2px;
    font-family: Helvetica, sans-serif;
    font-weight: 600;
    color: rgba(0,0,0,0.4);
    margin: 0 0 16px 0;
}

.comment .comment-content p {
    font-size: 20px;
    margin-bottom: 12px;
}

.comment .comment-content p > a {
    color: rgba(38, 142, 239, 1);
    padding: 0 0 1px 0;
    border-bottom: 2px solid rgba(38, 142, 239, 1);
    transition: color 0.5s ease, border-bottom 0.5s ease;
}

.comment .comment-content p > a:hover {
    color: rgba(0, 68, 181, 1);
    border-bottom: 2px solid rgba(38, 142, 239, 0.5);
}

.comment .comment-content .comment-reply-link {
    font-size: 8px;
    font-family: 'Helvetica', sans-serif;
    text-transform: uppercase;
    letter-spacing: 2px;
    font-weight: 600;
    color: white;
    text-align: center;
    padding: 4px 16px;
    background-color: rgba(0,0,0,0.20);
    transition: background-color 0.5s ease;
}

.comment .comment-content .comment-reply-link:hover {
    background-color: rgba(0,0,0,1);
}
<head>
    <meta charset="UTF-8">
    <title>FoodBlog - A WordPress Food Blog Theme</title>

    <meta http-equiv="X-UA-Compatible" content="IE-edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <!-- Main CSS -->
    <link href="css/comments-custom.css" rel="stylesheet">
</head>


<div id="comments" class="comments-area post-single-comments col-md-12">

	<div class="comments-title section-title">
		<p class="wrap">7 comments </p>		
	</div><!-- .comments-title -->

	<ul class="comments-list col-md-12">
		
			<li class="comment even thread-even depth-1 parent col-md-12" id="comment-3" itemprop="comment" itemscope itemtype="http://schema.org/Comment">
				<div class="comment-wrapper col-md-12">
					<img alt='Author’s gravatar' src='http://1.gravatar.com/avatar/13f401b35fbfa320cf306a891828f876?s=65&#038;d=%5Bdefault%20gravatar%20URL%5D&#038;r=g' srcset='http://1.gravatar.com/avatar/13f401b35fbfa320cf306a891828f876?s=130&#038;d=%5Bdefault%20gravatar%20URL%5D&#038;r=g 2x' class='avatar avatar-65 photo' height='65' width='65' />				
					<div class="info">
						<div class="comment-meta" role="complementary">
							<h2 class="comment-author">
								<a class="comment-author-link" href="" itemprop="author">Linda Calinda</a>
							</h2>
							<time class="comment-time" datetime="2017-12-29T05:00+00:00" itemprop="datePublished">29th December 2017, <a href="#comment-3" itemprop="url">5:00 am</a>
							</time>
							<a class="comment-edit-link" href="http://127.0.0.1/wordpress/wp-admin/comment.php?action=editcomment&#038;c=3"><p class="comment-meta-item">Edit this comment</p>
							</a>
						</div>
						<div class="comment-content" itemprop="text">
					        <p>Here we go, another link:<a href="https://www.google.com/" rel="nofollow">https://www.google.com/</a>
					        </p>
							
					        <a rel='nofollow' class='comment-reply-link' href='http://127.0.0.1/wordpress/2017/12/19/finding-the-love-of-your-life/?replytocom=3#respond' onclick='return addComment.moveForm( "comment-3", "3", "respond", "29" )' aria-label='Reply to Linda Calinda'>Reply</a>		
				    	</div>
					</div>
				</div>

				
				<ul class="child-comments col-md-12">

			
					<li class="comment odd alt depth-2 child col-md-11" id="comment-7" itemprop="comment" itemscope itemtype="http://schema.org/Comment">
						<div class="comment-wrapper col-md-12">
							<img alt='Author’s gravatar' src='http://1.gravatar.com/avatar/13f401b35fbfa320cf306a891828f876?s=65&#038;d=%5Bdefault%20gravatar%20URL%5D&#038;r=g' srcset='http://1.gravatar.com/avatar/13f401b35fbfa320cf306a891828f876?s=130&#038;d=%5Bdefault%20gravatar%20URL%5D&#038;r=g 2x' class='avatar avatar-65 photo' height='65' width='65' />				<div class="info">
								<div class="comment-meta" role="complementary">
									<h2 class="comment-author">
										<a class="comment-author-link" href="" itemprop="author">Dana Throws</a>
									</h2>
									<time class="comment-time" datetime="2018-01-01T18:22+00:00" itemprop="datePublished">1st January 2018, <a href="#comment-7" itemprop="url">6:22 pm</a></time>
									<a class="comment-edit-link" href="http://127.0.0.1/wordpress/wp-admin/comment.php?action=editcomment&#038;c=7"><p class="comment-meta-item">Edit this comment</p></a>											</div>
								<div class="comment-content" itemprop="text">
							        <p>REPLY:: Quite Interesting!</p>
									
							        <a rel='nofollow' class='comment-reply-link' href='http://127.0.0.1/wordpress/2017/12/19/finding-the-love-of-your-life/?replytocom=7#respond' onclick='return addComment.moveForm( "comment-7", "7", "respond", "29" )' aria-label='Reply to Dana Throws'>Reply</a>					</div>
							</div>
						</div>
					</li>

			
					<li class="comment even depth-2 child col-md-11" id="comment-9" itemprop="comment" itemscope itemtype="http://schema.org/Comment">
						<div class="comment-wrapper col-md-12">
							<img alt='Author’s gravatar' src='http://1.gravatar.com/avatar/13f401b35fbfa320cf306a891828f876?s=65&#038;d=%5Bdefault%20gravatar%20URL%5D&#038;r=g' srcset='http://1.gravatar.com/avatar/13f401b35fbfa320cf306a891828f876?s=130&#038;d=%5Bdefault%20gravatar%20URL%5D&#038;r=g 2x' class='avatar avatar-65 photo' height='65' width='65' />				<div class="info">
								<div class="comment-meta" role="complementary">
									<h2 class="comment-author">
										<a class="comment-author-link" href="" itemprop="author">Lorand Post</a>
									</h2>
									<time class="comment-time" datetime="2018-01-01T18:28+00:00" itemprop="datePublished">1st January 2018, <a href="#comment-9" itemprop="url">6:28 pm</a></time>
									<a class="comment-edit-link" href="http://127.0.0.1/wordpress/wp-admin/comment.php?action=editcomment&#038;c=9"><p class="comment-meta-item">Edit this comment</p></a>											</div>
								<div class="comment-content" itemprop="text">
							        <p>Him some great pleasure. To take a trivial example, which of us ever undertakes laborious physical exercise, except to obtain some advantage from it? But who has any right to find fault with a man who chooses to enjoy a pleasure that has no annoying consequences, or one who avoids a pain that produces no resultant pleasure?</p>
									
							        <a rel='nofollow' class='comment-reply-link' href='http://127.0.0.1/wordpress/2017/12/19/finding-the-love-of-your-life/?replytocom=9#respond' onclick='return addComment.moveForm( "comment-9", "9", "respond", "29" )' aria-label='Reply to Lorand Post'>Reply</a>					</div>
							</div>
						</div>

					
						<ul class="child-comments col-md-12">

					
							<li class="comment odd alt depth-3 child col-md-11" id="comment-10" itemprop="comment" itemscope itemtype="http://schema.org/Comment">
								<div class="comment-wrapper col-md-12">
									<img alt='Author’s gravatar' src='http://1.gravatar.com/avatar/13f401b35fbfa320cf306a891828f876?s=65&#038;d=%5Bdefault%20gravatar%20URL%5D&#038;r=g' srcset='http://1.gravatar.com/avatar/13f401b35fbfa320cf306a891828f876?s=130&#038;d=%5Bdefault%20gravatar%20URL%5D&#038;r=g 2x' class='avatar avatar-65 photo' height='65' width='65' />				<div class="info">
										<div class="comment-meta" role="complementary">
											<h2 class="comment-author">
												<a class="comment-author-link" href="" itemprop="author">Smithy</a>
											</h2>
											<time class="comment-time" datetime="2018-01-01T18:30+00:00" itemprop="datePublished">1st January 2018, <a href="#comment-10" itemprop="url">6:30 pm</a></time>
											<a class="comment-edit-link" href="http://127.0.0.1/wordpress/wp-admin/comment.php?action=editcomment&#038;c=10"><p class="comment-meta-item">Edit this comment</p></a>											</div>
										<div class="comment-content" itemprop="text">
									        <p>But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness. No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful. Nor again is there anyone who loves or pursues or desires to obtain pain of itself, because it is pain, but because occasionally circumstances occur in which toil and pain can procure him some great pleasure. To take a trivial example, which of us ever undertakes laborious physical exercise, except to obtain some advantage from it? But who has any right to find fault with a man who chooses to enjoy a pleasure that has no annoying consequences, or one who avoids a pain that produces no resultant pleasure? On the other hand, we denounce with righteous indignation and dislike men who are so beguiled and demoralized by the charms of pleasure of the moment, so blinded by desire, that they cannot foresee</p>
											
									        <a rel='nofollow' class='comment-reply-link' href='http://127.0.0.1/wordpress/2017/12/19/finding-the-love-of-your-life/?replytocom=10#respond' onclick='return addComment.moveForm( "comment-10", "10", "respond", "29" )' aria-label='Reply to Smithy'>Reply</a>					</div>
									</div>
								</div>
							</li>
						</ul>
					</li>

			
				</ul>

		
			</li>

		
			<li class="comment even thread-odd thread-alt depth-1 parent col-md-12" id="comment-8" itemprop="comment" itemscope itemtype="http://schema.org/Comment">
				<div class="comment-wrapper col-md-12">
					<img alt='Author’s gravatar' src='http://1.gravatar.com/avatar/13f401b35fbfa320cf306a891828f876?s=65&#038;d=%5Bdefault%20gravatar%20URL%5D&#038;r=g' srcset='http://1.gravatar.com/avatar/13f401b35fbfa320cf306a891828f876?s=130&#038;d=%5Bdefault%20gravatar%20URL%5D&#038;r=g 2x' class='avatar avatar-65 photo' height='65' width='65' />				
					<div class="info">
						<div class="comment-meta" role="complementary">
							<h2 class="comment-author">
								<a class="comment-author-link" href="" itemprop="author">hey@gmail.com</a>
							</h2>
							<time class="comment-time" datetime="2018-01-01T18:28+00:00" itemprop="datePublished">1st January 2018, <a href="#comment-8" itemprop="url">6:28 pm</a></time>
							<a class="comment-edit-link" href="http://127.0.0.1/wordpress/wp-admin/comment.php?action=editcomment&#038;c=8"><p class="comment-meta-item">Edit this comment</p></a>											</div>
						<div class="comment-content" itemprop="text">
					        <p>Greatness! 🙂</p>
							
					        <a rel='nofollow' class='comment-reply-link' href='http://127.0.0.1/wordpress/2017/12/19/finding-the-love-of-your-life/?replytocom=8#respond' onclick='return addComment.moveForm( "comment-8", "8", "respond", "29" )' aria-label='Reply to hey@gmail.com'>Reply</a>
					    </div>
					</div>
				</div>
			</li>
	</ul>
		
		
	<div id="respond" class="comment-respond">
		<h3 id="reply-title" class="comment-reply-title">Leave a Reply 
			<small>
				<a rel="nofollow" id="cancel-comment-reply-link" href="/wordpress/2017/12/19/finding-the-love-of-your-life/#respond" style="display:none;">Cancel reply
				</a>
			</small>
		</h3>
		<form action="http://127.0.0.1/wordpress/wp-comments-post.php" method="post" id="commentform" class="comment-form" novalidate>
			<p class="logged-in-as"><a href="http://127.0.0.1/wordpress/wp-admin/profile.php" aria-label="Logged in as admin. Edit your profile.">Logged in as admin</a>. 
				<a href="http://127.0.0.1/wordpress/wp-login.php?action=logout&amp;redirect_to=http%3A%2F%2F127.0.0.1%2Fwordpress%2F2017%2F12%2F19%2Ffinding-the-love-of-your-life%2F&amp;_wpnonce=f9fd35b4b5">Log out?
				</a>
			</p>
			<p class="comment-form-comment">
				<label for="comment">Comment</label> 
				<textarea id="comment" name="comment" cols="45" rows="8" maxlength="65525" aria-required="true" required="required">
				</textarea>
			</p>
			<p class="form-submit">
				<input name="submit" type="submit" id="submit" class="submit" value="Post Comment" /> 
				<input type='hidden' name='comment_post_ID' value='29' id='comment_post_ID' />
				<input type='hidden' name='comment_parent' id='comment_parent' value='0' />
			</p>
			<input type="hidden" id="_wp_unfiltered_html_comment_disabled" name="_wp_unfiltered_html_comment_disabled" value="4c1d9851b0" />
			<script>(function(){if(window===window.parent){document.getElementById('_wp_unfiltered_html_comment_disabled').name='_wp_unfiltered_html_comment';}})();
			</script>
		</form>
	</div><!-- #respond -->
</div><!-- #comments -->

在 SO 的代码容器中,这看起来不错,它使元素与 flex-start(以及 Firefox)对齐。

Chrome 除外。这是它的样子:

enter image description here

以下是来自 Chrome 的用户代理样式表:

.child-comments {
    display: flex;
    align-items: flex-end;
    flex-direction: column;
    height: auto;
}
@media (min-width: 768px)
comments-custom.css:24
.col-md-12 {
    -webkit-box-flex: 0;
    -webkit-flex: 0 0 100%;
    -ms-flex: 0 0 100%;
    flex: 0 0 100%;
    max-width: 100%;
}
comments-custom.css:3
.col-1, .col-2, .col-3, .col-4, .col-5, .col-6, .col-7, .col-8, .col-9, .col-10, .col-11, .col-12, .col, .col-sm-1, .col-sm-2, .col-sm-3, .col-sm-4, .col-sm-5, .col-sm-6, .col-sm-7, .col-sm-8, .col-sm-9, .col-sm-10, .col-sm-11, .col-sm-12, .col-sm, .col-md-1, .col-md-2, .col-md-3, .col-md-4, .col-md-5, .col-md-6, .col-md-7, .col-md-8, .col-md-9, .col-md-10, .col-md-11, .col-md-12, .col-md, .col-lg-1, .col-lg-2, .col-lg-3, .col-lg-4, .col-lg-5, .col-lg-6, .col-lg-7, .col-lg-8, .col-lg-9, .col-lg-10, .col-lg-11, .col-lg-12, .col-lg, .col-xl-1, .col-xl-2, .col-xl-3, .col-xl-4, .col-xl-5, .col-xl-6, .col-xl-7, .col-xl-8, .col-xl-9, .col-xl-10, .col-xl-11, .col-xl-12, .col-xl {
    position: relative;
    width: 100%;
    min-height: 1px;
}
comments-custom.css:1
ul {
    padding: 0;
}
user agent stylesheet
ol ul, ul ol, ul ul, ol ol {
    -webkit-margin-before: 0px;
    -webkit-margin-after: 0px;
}
user agent stylesheet
ul ul, ol ul {
    list-style-type: circle;
}
user agent stylesheet
ul, menu, dir {
    display: block;
    list-style-type: disc;
    -webkit-margin-before: 1em;
    -webkit-margin-after: 1em;
    -webkit-margin-start: 0px;
    -webkit-margin-end: 0px;
    -webkit-padding-start: 40px;
}
Inherited from li#comment-3.comment.even.thread-even.depth-1.parent.col-md-12
user agent stylesheet
li {
    display: list-item;
    text-align: -webkit-match-parent;
}
Inherited from ul.comments-list.col-md-12
user agent stylesheet
ul, menu, dir {
    display: block;
    list-style-type: disc;
    -webkit-margin-before: 1em;
    -webkit-margin-after: 1em;
    -webkit-margin-start: 0px;
    -webkit-margin-end: 0px;
    -webkit-padding-start: 40px
    }

可能是什么原因?

最佳答案

在多次涉猎和谷歌搜索重写的问题之后,我找到了罪魁祸首。

添加

<!DOCTYPE html>

您的文档允许您的样式表优先于其他所有内容,Chrome 不再输入自己的样式。

关于html - 为什么 Chrome 会拉伸(stretch) 'align-items' 而不是像声明的那样将它们对齐到 'flex-end'?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48088263/

相关文章:

java - 如何使用 OpenOffice API 将 HTML 文本放入 OpenOffice 文档

jquery - 用你自己的 css 覆盖 css

css - 如何拥有固定元素(例如 float : right) in a flex layout?

css - 图像流向下一行而不是在 flexbox 两列布局中缩小

css - 在 Flex 中调整表格大小,同时保持纵横比,如何?

html - 用一个扩展的 div float 一系列固定宽度的 div

jquery - 将按钮放置在图像悬停上

javascript - 在 Angular 中重用 HTML 端的计算文本?

javascript - 在 div 下传递的链接仍然可以点击吗?

java - Jsoup 匹配任何具有命名空间的元素