Blazor - Padding/Margin Issues with Dynamically created <li> - html

Framework: .Net6.0
C#: 10.0
I'm using the following code, which partly comes comes from: https://www.w3schools.com/howto/howto_css_calendar.asp
<div>
<div class="month">
<ul>
<li>
#DateTime.Today.ToString("MMMM")<br>
<span style="font-size:18px">#DateTime.Today.Year</span>
</li>
</ul>
</div>
<ul class="weekdays">
<li class="border border-secondary">Mo</li>
<li class="border border-secondary">Tu</li>
<li class="border border-secondary">We</li>
<li class="border border-secondary">Th</li>
<li class="border border-secondary">Fr</li>
<li class="border border-secondary">Sa</li>
<li class="border border-secondary">Su</li>
</ul>
<ul class="days">
<li class="border border-secondary">x</li>
<li class="border border-secondary">x</li>
<li class="border border-secondary">x</li>
#for (int y = 0; y < (int)DateTime.Today.StartOfMonth().AddDays(-1).DayOfWeek; y++) {
<li class="border border-secondary"></li>
}
#for (int x = 1; x < DateTime.DaysInMonth(DateTime.Today.Year, DateTime.Today.Month) + 1; x++) {
if (x == DateTime.Today.Day) {
<li class="border border-secondary"><span class="active">#x</span></li>
} else {
<li class="border border-secondary">#x</li>
}
}
</ul>
</div>
The issue comes from the Dynamically created <li> tags.
The ones created manually have a padding which is needed, however when the same <li> tag is created dynamically, there is no padding. Does anyone know why this happens?
EDIT:
#preservewhitespace true at the top of the razor file fixed this issue. Editor shows error, but still compiles and adds all the padding.

Related

jQuery toggle class on sub element of li - not working

So I have multiple LI's like below as it's a menu and I am trying to create a drop-down but for some reason, my jQuery code is not working. Can someone help me?
FYI I can't change HTML as it's dynamically generating in Shopify. I can only change jQuery and CSS
<li class="grid__item lvl-1 ">
<a class="site-nav lvl-1 light-body">Furry Artist</a>
<ul class="subLinks inactive">
<li class="lvl-2">
Erdbeer Joghurt
</li>
<li class="lvl-2">
Jeson RC
</li>
</ul>
</li>
$( document ).ready(function() {
$("ul.subLinks").addClass("inactive");
});
$('a.site-nav.lvl-1').click(function() {
$(this).find("ul.subLinks").toggleClass('active-drop-down');
});
.inactive {
display:none;
}
.active-drop-down {
display:block !important;
}
Your issue is $(this).find... in the a click handler - at this point, this is the a.
.find() looks at the selectors children - but the menu is not a child of the a, it's a sibling.
Change to
$(this).closest("li").find("ul.subLinks"...
(maybe $(this).next().toggleClass... with a caveat on .this() that it's always the very next element).
Updated snippet:
$('a.site-nav.lvl-1').click(function() {
$(this).closest("li").find("ul.subLinks").toggleClass('active-drop-down');
});
.inactive {
display:none;
}
.active-drop-down {
display:block !important;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<ol>
<li class="grid__item lvl-1 ">
<a class="site-nav lvl-1 light-body">Furry Artist</a>
<ul class="subLinks inactive">
<li class="lvl-2">
Erdbeer Joghurt
</li>
<li class="lvl-2">
Jeson RC
</li>
</ul>
</li>
</ol>

How can I get images into my li from a wordpress gallery with a loop

I'm making a WordPress website and I created everything outside of it. Now i'm getting it all together but I'm pretty new to this. I would like to create a Wordpress loop to get images from a gallery, replacing the img tag.
------- Edited -------
So there was a small change in the design but same problem. I need to get the images from a gallery in Wordpress to fill two slideshows with the same images.
<div id="slider1">
<ul>
<li class="mySlides1">
<img src="images_1.jpg">
</li>
<li class="mySlides1">
<img src="images_3.jpg">
</li>
<li class="mySlides1">
<img src="images_2.jpg">
</li>
<li class="mySlides1">
<img src="images_4.jpg">
</li>
</ul>
</div>
<div id="slider2">
<ul>
<li class="mySlides2">
<img src="images_1.jpg">
</li>
<li class="mySlides2">
<img src="images_3.jpg">
</li>
<li class="mySlides2">
<img src="images_2.jpg">
</li>
<li class="mySlides2">
<img src="images_4.jpg">
</li>
</ul>
</div>
I edited the question
As the question has been updated, I'm updating my answer to fit the new requirements. Basically, I've just added a parameter to the _GetSSImages() function. This allows you to pull the images from a specific slideshow, assuming that the class="" is unique for each slideshow. If not, then I would need to adjust the structure of the function.
----Original answer with updated code:
There are few things I don't know, such as how you intend to display the list of images from the slideshow, or how the client will edit this list.
However, you can use the javascript function below to grab all of the image src attributes from the slideshow HTML based on what you've shown here. The function returns an array of all src attributes so you can call it wherever you need to in your code to get the list.
function _GetSSImages(slide) {
var slideEls = document.querySelectorAll(slide),
slideImgs = [];
for(var i = 0; i < slideEls.length; i++) {
if(slideEls[i].querySelector("img").src != null) slideImgs.push(slideEls[i].querySelector("img").src);
}
return slideImgs;
}
var slideShow1 = _GetSSImages("mySlides1"),
slideShow2 = _GetSSImages("mySlides2");
<div id="slider1">
<ul>
<li class="mySlides1">
<img src="images_1.jpg">
</li>
<li class="mySlides1">
<img src="images_3.jpg">
</li>
<li class="mySlides1">
<img src="images_2.jpg">
</li>
<li class="mySlides1">
<img src="images_4.jpg">
</li>
</ul>
</div>
<div id="slider2">
<ul>
<li class="mySlides2">
<img src="images_1.jpg">
</li>
<li class="mySlides2">
<img src="images_3.jpg">
</li>
<li class="mySlides2">
<img src="images_2.jpg">
</li>
<li class="mySlides2">
<img src="images_4.jpg">
</li>
</ul>
</div>

using flex grow for creating tournmanet brackets

I am creating a tournmanet bracket with vue, and I am using this code as start point: https://codepen.io/aronduby/pen/qliuj but I am using a v-for for generating the brackets
<ul v-for="j in jTotal>
<div v-for="i in iTotal"
v-if="!loading && matriz[j-1][i-1]"
class="test"
>
<li class="spacer"> </li>
<li class="game game-top winner">person 1 <span>79</span></li>
<li class="game game-spacer" > </li>
<li class="game game-bottom ">person 2 <span>48</span></li>
<li class="spacer"> </li>
</div>
</ul>
But as I have this div wrapping the li, I lost the flex-grow property that is being used in the example because I generate the structure
<ul>
<div>
<li>
So I would like to know if there is how I keep the property grow wrapping the 5 li that make up a game.
Thanks

DSpace: images appears just at initial page

My code is as follows:
<h3 class="ds-option-set-head">Compartilhar</h3>
<div class="ds-option-set" id="sharebar">
<ul>
<li onclick="shareFunction('fb')"><img src="themes/UFSC_producao/images/facebook.svg"></img></li>
<li onclick="shareFunction('tw')"><img src="themes/UFSC_producao/images/twitter.svg"></img></li>
<li onclick="shareFunction('lk')"><img src="themes/UFSC_producao/images/linkedin.svg"></img></li>
<li onclick="shareFunction('gp')"><img src="themes/UFSC_producao/images/google-plus.svg"></img></li>
</ul>
</div>
These images just appears at the initial page mysite/xmlui and I don't know why. Any suggestions?

Full height background-color on list item requires padding or overflow?

I have a solution for my problem, but it doesn't seem right. I want to know what's going on.
Nested list item's background colour doesn't extend to the bottom even though there's no margin on it (see the gap below the blue background in the screen shots). The paragraph inside does have a margin. But I've tried to reproduce this outside of my app (which uses Bootstrap) and I can't. In Firebug I tried turning off all CSS except that which was necessary to show the problem (i.e., the background-color and border -- see 2nd image), but it makes no difference. Seen in Chrome and Firefox.
The fix is either adding bottom padding or overflow-y:auto; to the inner list item. But why? Has anyone encountered something like this?
I can't post all the code here, but the HTML at least is something like this:
<ul class="nav navbar-nav navbar-right">
<li class="dropdown open">
<ul class="dropdown-menu notification-list">
<li class="notification-new">
<div class="text-muted">01/13/2015</div>
<p>Check out the new features coming to the 2015.1 release here!</p>
</li>
<li class="notification-new">
<div class="text-muted">12/24/2014<button class="close" type="button"><span class="sr-only">Close</span></button></div>
<p>Upcoming server maintenance scheduled for 11:00pm PST.</p>
</li>
[Update] Here is a simplified, non-Bootstrap version. Why no gaps in this one?
ul {
width: 300px;
border: 1px solid red;
float: left;
}
li.sub {
border: 1px solid green;
background-color: yellow;
padding: 8px 8px 0;
}
p { margin:10px; /* no gaps with or without this */ }
<ul>
<li><p>item 1</p>
<ul>
<li class="sub">
<div>
something
</div>
<p>
stuff
</p>
</li>
<li class="sub">
<div>
something
</div>
<p>
stuff
</p>
</li>
</ul>
</li>
<li>thing
<ul>
<li class="sub">
nuther
</li>
</ul>
</li>
</ul>
The spacing is occurring because of the margins in the p elements inside the lis, specifically the bottom margin.
This behavior is defined as 'collapsing margins'. More info here: http://www.w3.org/TR/CSS2/box.html#collapsing-margins
You can see this by setting them to 0.
.notification-new p{
margin:0;
}
Live example: http://www.bootply.com/wlfIl3RziC
Full code below:
.notification-new {
background-color:red;
}
.notification-new p{
margin:0;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet"/>
<ul class="nav navbar-nav navbar-right">
<li class="dropdown open">
<ul class="dropdown-menu notification-list">
<li class="notification-new">
<div class="text-muted">01/13/2015</div>
<p>Check out the new features coming to the 2015.1 release here!</p>
</li>
<li class="notification-new">
<div class="text-muted">12/24/2014<button class="close" type="button"><span class="sr-only">Close</span></button></div>
<p>Upcoming server maintenance scheduled for 11:00pm PST.</p>
</li>
</ul>
</li>
</ul>