Skip to content

Commit 0ca97d3

Browse files
committed
Estilizando el dropdown y haciendo verdaderamente un dropup
1 parent 88a5912 commit 0ca97d3

File tree

3 files changed

+37
-16
lines changed

3 files changed

+37
-16
lines changed

_includes/elements/dropdown.html

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,13 @@
1-
{% if site.production %}
2-
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" />
3-
{% else %}
4-
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" />
5-
{% endif %}
6-
7-
<span class="dropdown">
1+
<span class="dropdown dropup">
82
<button class="btn btn-secondary dropdown-toggle" type="button" id="playGameDropdown" data-bs-toggle="dropdown" aria-expanded="false">
93
Play a game!
104
</button>
115
<ul class="dropdown-menu dropdown-menu-dark" aria-labelledby="playGameDropdown">
126
{% for game in include.source %}
13-
<li><a class="dropdown-item" href="{{ game.url }}">{{ game.name }}</a></li>
7+
<li>
8+
<a class="dropdown-item" href="{{ game.url }}" target="_blank">{{ game.name }}</a>
9+
</li>
1410
{% endfor %}
1511
</ul>
1612
</span>
1713

18-
{% if site.production %}
19-
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>
20-
{% else %}
21-
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>
22-
{% endif %}
23-

_includes/scripts.html

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,23 @@
2020
$('[data-toggle="tooltip"]').tooltip()
2121
})
2222
</script>
23+
24+
<!-- If the site is in production, include the Bootstrap CSS from a CDN.
25+
The CDN is used for faster loading as it uses global servers.
26+
If the site is not in production (i.e., in development), the same link is used,
27+
but you could customize this further if needed. -->
28+
{% if site.production %}
29+
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" />
30+
{% else %}
31+
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" />
32+
{% endif %}
33+
34+
35+
<!-- Bootstrap JavaScript file (with Popper.js bundled) is required for interactive components like dropdowns, modals, etc.
36+
The script is loaded from a CDN for fast access from global servers.
37+
The production/development conditional allows you to configure different setups if needed. -->
38+
{% if site.production %}
39+
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>
40+
{% else %}
41+
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>
42+
{% endif %}

_sass/_dropdown.scss

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,28 @@
66
}
77

88
.dropdown-menu {
9-
max-width: 250px;
9+
max-width: 250px;
1010
padding: 0.5rem;
1111
background-color: #343a40;
1212
border-radius: 8px;
1313
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
1414
border: none;
1515
margin-top: 0.25rem;
16+
position: absolute;
17+
bottom: 100%;
18+
}
19+
20+
.dropdown.dropup .dropdown-menu {
21+
margin-bottom:5rem;
22+
margin-top: 0;
23+
bottom: 100%;
1624
}
1725

1826
.dropdown-item {
27+
display: block;
1928
color: #f8f9fa;
29+
padding: 0.5rem 1rem;
30+
2031
&:hover {
2132
background-color: #495057;
2233
color: #fff;
@@ -31,7 +42,7 @@
3142
font-size: 1rem;
3243
border-radius: 5px;
3344
cursor: pointer;
34-
45+
3546
&:focus {
3647
outline: none;
3748
box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);

0 commit comments

Comments
 (0)