gpt4 book ai didi

css - HTML 未按预期呈现

转载 作者:太空宇宙 更新时间:2023-11-04 09:20:37 25 4
gpt4 key购买 nike

我正在尝试复制 this 上的“服务选项卡”部分页,和 here是源代码。

我希望它看起来像这样:

screen1

我已经设法让它显示:

myScreen

下面是我的ASPX:

 <asp:Repeater ID="rptGroupDescriptions" runat="server" OnItemDataBound="rptGroupDescriptions_ItemDataBound" OnItemCommand="rptGroupDescriptions_ItemCommand">
<ItemTemplate>
<ul id="myTab" class="nav nav-tabs nav-justified">
<li>
<a href="#service-<%#Eval("Group_Id") %>" data-toggle="tab"><%#Eval("Group_Name")%></a>
</li>
</ul>

<div id="myTabContent" class="tab-content">
<div class="tab-pane fade active in" id="service-<%#Eval("Group_Id") %>">
<h4><%#Eval("Group_Name")%></h4>
<p><%#Eval("Group_Desc")%></p>
</div>
</div>
</ItemTemplate>
</asp:Repeater>

这是我使用的示例代码:

 <ul id="myTab" class="nav nav-tabs nav-justified">
<li class="active"><a href="#service-one" data-toggle="tab"><i class="fa fa-tree"></i> Service One</a>
</li>
<li class=""><a href="#service-two" data-toggle="tab"><i class="fa fa-car"></i> Service Two</a>
</li>
<li class=""><a href="#service-three" data-toggle="tab"><i class="fa fa-support"></i> Service Three</a>
</li>
<li class=""><a href="#service-four" data-toggle="tab"><i class="fa fa-database"></i> Service Four</a>
</li>
</ul>

<div id="myTabContent" class="tab-content">
<div class="tab-pane fade active in" id="service-one">
<h4>Service One</h4>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quae repudiandae fugiat illo cupiditate excepturi esse officiis consectetur, laudantium qui voluptatem. Ad necessitatibus velit, accusantium expedita debitis impedit rerum totam id. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Natus quibusdam recusandae illum, nesciunt, architecto, saepe facere, voluptas eum incidunt dolores magni itaque autem neque velit in. At quia quaerat asperiores.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quae repudiandae fugiat illo cupiditate excepturi esse officiis consectetur, laudantium qui voluptatem. Ad necessitatibus velit, accusantium expedita debitis impedit rerum totam id. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Natus quibusdam recusandae illum, nesciunt, architecto, saepe facere, voluptas eum incidunt dolores magni itaque autem neque velit in. At quia quaerat asperiores.</p>
</div>
<div class="tab-pane fade" id="service-two">
<h4>Service Two</h4>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quae repudiandae fugiat illo cupiditate excepturi esse officiis consectetur, laudantium qui voluptatem. Ad necessitatibus velit, accusantium expedita debitis impedit rerum totam id. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Natus quibusdam recusandae illum, nesciunt, architecto, saepe facere, voluptas eum incidunt dolores magni itaque autem neque velit in. At quia quaerat asperiores.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quae repudiandae fugiat illo cupiditate excepturi esse officiis consectetur, laudantium qui voluptatem. Ad necessitatibus velit, accusantium expedita debitis impedit rerum totam id. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Natus quibusdam recusandae illum, nesciunt, architecto, saepe facere, voluptas eum incidunt dolores magni itaque autem neque velit in. At quia quaerat asperiores.</p>
</div>
<div class="tab-pane fade" id="service-three">
<h4>Service Three</h4>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quae repudiandae fugiat illo cupiditate excepturi esse officiis consectetur, laudantium qui voluptatem. Ad necessitatibus velit, accusantium expedita debitis impedit rerum totam id. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Natus quibusdam recusandae illum, nesciunt, architecto, saepe facere, voluptas eum incidunt dolores magni itaque autem neque velit in. At quia quaerat asperiores.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quae repudiandae fugiat illo cupiditate excepturi esse officiis consectetur, laudantium qui voluptatem. Ad necessitatibus velit, accusantium expedita debitis impedit rerum totam id. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Natus quibusdam recusandae illum, nesciunt, architecto, saepe facere, voluptas eum incidunt dolores magni itaque autem neque velit in. At quia quaerat asperiores.</p>
</div>
<div class="tab-pane fade" id="service-four">
<h4>Service Four</h4>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quae repudiandae fugiat illo cupiditate excepturi esse officiis consectetur, laudantium qui voluptatem. Ad necessitatibus velit, accusantium expedita debitis impedit rerum totam id. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Natus quibusdam recusandae illum, nesciunt, architecto, saepe facere, voluptas eum incidunt dolores magni itaque autem neque velit in. At quia quaerat asperiores.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quae repudiandae fugiat illo cupiditate excepturi esse officiis consectetur, laudantium qui voluptatem. Ad necessitatibus velit, accusantium expedita debitis impedit rerum totam id. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Natus quibusdam recusandae illum, nesciunt, architecto, saepe facere, voluptas eum incidunt dolores magni itaque autem neque velit in. At quia quaerat asperiores.</p>
</div>
</div>

我假设一个问题可能是我没有将 class="Active"添加到列表项,但我不能,因为这样每个列表项都会有该类。

所以这也是我的代码隐藏代码:

//Trying to display group descriptions using repeater
SqlConnection connGroupDesc;
string connStringGroupDesc = ConfigurationManager.ConnectionStrings[
"BallinoraDBConnectionString1"].ConnectionString;
connGroupDesc = new SqlConnection(connStringGroupDesc);
SqlDataAdapter sdaGroupDesc = new SqlDataAdapter("SELECT * FROM Groups", connGroupDesc);
DataTable dtGroupDesc = new DataTable();
sdaGroupDesc.Fill(dtGroupDesc);
rptGroupDescriptions.DataSource = dtGroupDesc;
rptGroupDescriptions.DataBind();

谁能建议我如何改进上面的代码来解决这个问题?

最佳答案

您可以在 ItemTemplate 中使用三元运算符它使用 ItemIndex

<ul id="myTab" class="nav nav-tabs nav-justified" <%# Container.ItemIndex == 0 ? "class=\"Active\"" : string.Empty %>>

这条路只有第一个<ul>会有一个 Active类。

关于css - HTML 未按预期呈现,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41510946/

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