gpt4 book ai didi

javascript - 在 anchor 内对齐 div

转载 作者:行者123 更新时间:2023-11-28 15:26:07 25 4
gpt4 key购买 nike

我想要 <div class="status">@Resource.AccordionStatus</div> div 与“@item.Title”对齐。 div 当前正在垂直居中。

//Accordion-----------------------------------------------
$(document).ready(function() {
$(".accordion-desc").fadeOut(0);
$(".accordion").click(function() {
$(".accordion-desc").not($(this).next()).slideUp('fast');
$(this).next().slideToggle(400);
});
});

$(".accordion").click(function() {
$(".accordion").not(this).find(".rotate").removeClass("down");
$(this).find(".rotate").toggleClass("down");
});
//-----------------------------------------------------------
body {
background-color: #eee;
font-family: "Open Sans", sans-serif;
}

header {
background-color: #2cc185;
color: #fff;
padding: 2em 1em;
margin-bottom: 1.5em;
}

h1 {
font-weight: 300;
text-align: center;
}

.container {
position: relative;
margin: 0 auto;
}

button {
background-color: #2cc185;
color: #fff;
border: 0;
padding: 1em 1.5em;
}

button:hover {
background-color: #239768;
color: #fff;
}

button:focus {
background-color: #239768;
color: #fff;
}

.accordion {
position: relative;
background-color: #fff;
display: inline-block;
width: 100%;
border-top: 1px solid #f1f4f3;
border-bottom: 1px solid #f1f4f3;
font-weight: 700;
color: #74777b;
vertical-align: middle;
}


/*Rotation-------------------------------------*/

.accordion .fa {
position: relative;
float: right;
}

.rotate {
-moz-transition: all 0.1s linear;
-webkit-transition: all 0.1s linear;
transition: all 0.1s linear;
}

.rotate.down {
-moz-transform: rotate(90deg);
-webkit-transform: rotate(90deg);
transform: rotate(90deg);
}


/*------------------------------------------*/

.link {
text-align: right;
margin-bottom: 20px;
margin-right: 30px;
}

.accordion h4 {
position: relative;
top: 0.8em;
margin: 0;
font-size: 14px;
font-weight: 700;
}

.accordion a {
position: relative;
display: block;
color: #74777b;
padding: 1em 1em 2.5em 1em;
text-decoration: none;
}

.accordion a:hover {
text-decoration: none;
color: #2cc185;
background-color: #e7ecea;
transition: 0.3s;
}

.accordion-desc {
background-color: #f1f4f3;
color: #74777b;
z-index: 2;
padding: 20px 15px;
}

@media (min-width:480px) {
.container {
max-width: 80%;
}
}

@media (min-width:768px) {
.container {
max-width: 1000px;
}
}

.accordion-desc p {
word-break: break-all;
}

.status {
position: relative;
float: right;
right: 20%;
vertical-align: middle;
}

.btn {
margin-top: 10px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.1/jquery.min.js"></script>
<div class="accordion">
<a href="#">
<h4>@item.Title</h4>
<div class="status">@Resource.AccordionStatus</div>
<i class="fa fa-chevron-right rotate"></i>
</a>
</div>
<div class="accordion-desc">
<h3>@Resource.AccordionProjectLead</h3>
<h4>Kay Wiberg</h4>
<h3>@Resource.AccordionDescription</h3>
<p>
@item.Description
<p>
<div class="link">
<a href="@item.Url">@Resource.AccordionGoTo</a>
</div>
</div>

最佳答案

请更新以下类。

.accordion h4 {
position: relative;
margin: 0;
font-size: 14px;
font-weight: 700;
float: left;
}

所做的更改:

删除了 top: 0.8em; 并且刚刚添加了 float:left

问题是 h4 标签占据了整个宽度,而 div 标签在逻辑上设置在与右侧对齐的新行中。

关于javascript - 在 anchor 内对齐 div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45215965/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com