Create repeated horizontal dividers between icon images - html

This is what it currently looks like:
I'm having trouble putting horizontal dividers between my icon images using angular, html, css. What I want to achieve is:
icon ---------- icon ---------- icon --------- icon
This is my code:
<div *ngFor="let item of parking; let i = index">
<div *ngIf="i == 0 || i == 1 || i == 2" class="divider">
<img src="http://cdn.appwinit.com/home/{{ item.image }}/image.png" alt="{{ item.title }}" srcset="http://cdn.appwinit.com/home/{{ item.image }}/image#2x.png 2x, http://cdn.appwinit.com/home/{{ item.image }}/image#3x.png 3x" style="height: 69px; width: 69px; display: block; margin: auto;"/>
<span class="horizontal-divider"></span>
</div>
<div *ngIf="i == 3" class="divider">
<img src="http://cdn.appwinit.com/home/{{ item.image }}/image.png" alt="{{ item.title }}" srcset="http://cdn.appwinit.com/home/{{ item.image }}/image#2x.png 2x, http://cdn.appwinit.com/home/{{ item.image }}/image#3x.png 3x" style="height: 69px; width: 69px; display: block; margin: auto;"/>
</div>
</div>
<div *ngFor="let item of parking; let i = index" class="col-xs-12 col-sm-3">
<p class="color-blue text-uppercase" style="font-size: 13px; margin-top: 20px;">{{ item.title }}</p>
<p class="opacity-65" style="font-size: 13px;" [innerHTML]="short ? item.short : item.body"></p>
</div>
This is my css:
div.divider {
display: flex;
flex-direction: row;
align-items: center;
}
div.divider {
flex-shrink: 0;
}
div.divider span.horizontal-divider {
width: 100%;
flex-shrink: 1;
border-bottom: 1px solid black;
margin: 5px
}

Related

Trouble positioning elements in CSS

I would very much appreciate help solving this problem:
HTML (ignore the django code):
.dp-thlykym-gyshh-lsvknym .specific-process {
align-items: center;
background-color: var(--white);
border-radius: 0.26vw;
box-shadow: 0.0vw 10.0vw 40.0vw #0000000d;
display: flex;
gap: 14.32vw;
height: 3.65vw;
justify-content: center;
padding: 2.08vw 1.56vw;
width: 77.55vw;
}
.dp-thlykym-gyshh-lsvknym .four-buttons-frame {
align-items: center;
display: flex;
gap: 1.04vw;
margin-bottom: -1.56vw;
margin-left: -1.04vw;
margin-top: -1.56vw;
width: 40vw;
}
.dp-thlykym-gyshh-lsvknym .icon-trash {
height: 1.88vw;
min-width: 1.88vw;
}
.dp-thlykym-gyshh-lsvknym .document {
height: 1.88vw;
min-width: 1.88vw;
}
.dp-thlykym-gyshh-lsvknym .secondery-action-btn {
align-items: center;
background-color: var(--white);
border: 0.1vw solid;
border-color: var(--red);
border-radius: 0.26vw;
display: flex;
gap: 0.52vw;
height: 2.6vw;
justify-content: center;
padding: 0.78vw 1.04vw;
width: 6.51vw;
}
<div class="specific-process">
<div class="four-buttons-frame">
{% if not assignment.is_active %}
<img class="icon-trash" src="{% static '/images/img/home/delete-1.svg' %}" alt="icon-trash" /> {% endif %} {% if assignment.active_task.is_under_review %}
<img class="document" src="{% static '/images/img/home/document.svg' %}" alt="document" /> {% endif %} {% if assignment.is_active %}
<div class="secondery-action-btn">
<div class="text text">עצור תהליך</div>
</div>
{% endif %}
</div>
<div class="nested-contents-frame">
<div class="steps">
<div class="x00 text">{{assignment.active_task.index}}/{{assignment.template.tasks.count}}</div>
</div>
<img class="line" src="{% static '/images/img/home/line-2.svg' %}" alt="Line 2" />
<div class="customer-added">
<div class="frame-2">
<div class="text_label text">{{assignment.client}}</div>
<div class="rectangle-11-1"></div>
</div>
</div>
<img class="line" src="{% static '/images/img/home/line-2.svg' %}" alt="Line 1" />
<div class="type-input-with-hover">
<div class="texticon-layout">
<div class="text-1 text-4 text">{{assignment}}</div>
</div>
</div>
</div>
</div>
{% endfor %}
Depending on the situation, there might be 2 elements on the left instead of just one. (talking about the red button and the svg icon) in each row. I would those to stick to the right of the supposed column and I can't manage to do so. Any help?

How to align colored text on the same line

So as you can see in the picture below, I want to put the colored text on the same line as the other test (beside Balance).
I tried many things but nothing worked, here is my html file
.card-header p {
color: #668eee;
}
.card {
max-width: 600px;
margin: auto;
}
.GreenTextColor {
color: #33FF3C;
}
.RedTextColor {
color: red;
}
<div class="container">
<div class="card">
<div class="card-header">
<br> Account: {{ things.accountid }}
</div>
<div class="card-body">
Balance: End: {{things.enddate}} Result: Not passed {% if things.balance >= 50000 %}
<div class="GreenTextColor">
{{things.balance}}
</div>
{% else %}
<div class="RedTextColor">
{{things.balance}}
</div>
</div>
</div>
Add display: flex; to .card-body.
.card-header p {
color: #668eee;
}
.card {
max-width: 600px;
margin: auto;
}
.GreenTextColor {
color: #33FF3C;
}
.RedTextColor {
color: red;
}
.card-body {
display: flex;
}
<div class="container">
<div class="card">
<div class="card-header">
<br> Account: {{ things.accountid }}
</div>
<div class="card-body">
Balance:
<div class="GreenTextColor">
{{things.balance}}
</div>
<div class="RedTextColor">
{{things.balance}}
</div>
</div>
</div>

div dropdown not showing

I am attempting to create a dropdown for a user. The problem is that it doesn't show up at all.
<div class="account-wrap">
<div class="inside-account trade-sell-div">
<a class = "trade-sell-button" href="{% url 'product' %}">Trade/Sell</a>
</div>
{% if user.is_authenticated %}
<div class = "inside-account chat-box-dropdown">
<a class="imgs-signed-in"><img style="height:45px !important;" src = "{% static "imgs/chat-box.png" %}" alt="Chat Box"></a>
</div>
<div class="inside-account user-dropdown">
<a class="imgs-signed-in user-icon-dropdown"><img src="{% static "imgs/user-icon.png" %}" alt="User"></a>
<div class="dropdown-frame">
<div id="triangle"></div>
<div class="dropdown-wrapper">
<hr>
</div>
</div>
</div>
{% else %}
<div class="inside-account">
Login
</div>
{% endif %}
</div>
css
.dropdown-frame{
position: absolute;
height: 40rem;
width: 10rem;
outline: 1px solid black;
}
#triangle {
width: 0;
height: 0;
content: '';
border-left: 20px solid transparent;
border-right: 20px solid transparent;
border-bottom: 20px solid white;
}
.dropdown-wrapper {
right: 0;
height: 40rem;
width: 10rem;
top: 56px;
border: 1px solid red;
z-index: 122;
}
Basically the triangle shows up on the nav bar but the part under the triangle does not show up at all. When I move the div elements outside the nav, it actually shows up. Does anyone have any explanation as to why my div dropdown-wrapper does not show up?
I believe you missed the . before dropdown-frame class
It should be {% if request.user.is_authenticated %} instead of {% if user.is_authenticated %}

How to set class=service-block sizes to a uniform height?

I'm adjusting the html / css on a hugo theme, but can't find resources on setting text boxes to a uniform height. Image shows current boxes, with height varying according to amount of text.
The text boxes look like:
The theme partial /layouts/partials/service.html looks like this:
{{"<!-- /section title -->" | safeHTML }}
{{ range .Site.Data.service.serviceItem}}
{{"<!-- Single Service Item -->" | safeHTML }}
<article class="col-lg-3 col-md-3 col-12 wow fadeInUp" data-wow-duration="500ms">
<div class="service-block text-center">
<div class="service-icon text-center">
<i class="{{ .icon }}"></i>
</div>
<h3>{{ .title }}</h3>
<p>{{ .content }}</p>
</div>
</article>
{{"<!-- End Single Service Item -->" | safeHTML }}
{{ end }}
and the CSS for the section looks like:
.service-2 .service-item {
border: 1px solid #eee;
margin-bottom: 30px;
padding: 50px 20px;
transition: all 0.3s ease 0s;
}
.service-2 .service-item:hover {
box-shadow: 0 5px 65px 0 rgba(0, 0, 0, 0.15);
-webkit-box-shadow: 0 5px 65px 0 rgba(0, 0, 0, 0.15);
}
.service-2 .service-item:hover i {
background: #fff;
color: #57cbcc;
}
.service-2 .service-item i {
font-size: 30px;
display: inline-block;
background: #57cbcc none repeat scroll 0 0;
border-radius: 30px;
box-shadow: 0 5px 6px 0 rgba(0, 0, 0, 0.1);
color: #fff;
height: 200px;
line-height: 55px;
margin-bottom: 20px;
width: 55px;
transition: all 0.3s ease 0s;
}
Is there a way to set a fixed height on those text boxes?
You don't need js for this job. Add display: flex to the container of the blocks will do. The shorter children of the container will "grow up" to fit into the container.
.flexcontainer{
display: flex;
}
.flexchild{
border: solid;
word-wrap: break-word;
width: 100px;
}
<div class="flexcontainer">
<div class="flexchild">
<h3>title </h3>
<p>asdf</p>
</div>
<div class="flexchild">
<h3>title </h3>
<p>asdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdf</p>
</div>
<div class="flexchild">
<h3>title </h3>
<p>asdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdf</p>
<p>asdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdf</p>
</div>
</div>
codepen
I find this flexbox guide to be useful
function getHeight(el) {
var styles = window.getComputedStyle(el);
var height = el.offsetHeight;
var borderTopWidth = parseFloat(styles.borderTopWidth);
var borderBottomWidth = parseFloat(styles.borderBottomWidth);
var paddingTop = parseFloat(styles.paddingTop);
var paddingBottom = parseFloat(styles.paddingBottom);
return height - borderBottomWidth - borderTopWidth - paddingTop - paddingBottom;
}
var heightList = [];
document.querySelectorAll('.service-block').forEach(function(el) {
heightList.push(getHeight(el))
})
var maxHeight = Math.max.apply(Math, heightList);
document.querySelectorAll('.service-block').forEach(function(el) {
el.style.height = maxHeight + "px";
})
.service-block {
width: 100px;
background-color: #eee;
padding: 10px;
}
.service-block p {
word-break: break-all;
}
.col-md-3 {
width: 33%;
float: left;
}
<body>
<div class="row">
<div class="col-md-3">
<div class="service-block text-center">
<div class="service-icon text-center">
<i class="fa fa-star"></i>
</div>
<h3>title</h3>
<p>content</p>
</div>
</div>
<div class="col-md-3">
<div class="service-block text-center">
<div class="service-icon text-center">
<i class="fa fa-star"></i>
</div>
<h3>title</h3>
<p>content.content.content.content.content.content</p>
</div>
</div>
<div class="col-md-3">
<div class="service-block text-center">
<div class="service-icon text-center">
<i class="fa fa-star"></i>
</div>
<h3>title</h3>
<p>content.content.content.content.content.contentcontent.content.content.content.content.contentcontent.content.content.content.content.contentcontent.content.content.content.content.contentcontent.content.content.content.content.contentcontent.content.content.content.content.contentcontent.content.content.content.content.content</p>
</div>
</div>
</div>
</body>
This is my way, get the maximum height and set it to each container.

Center align two divs in the same row

I have a JavaScript script that basically hides a box upon clicking the top two boxes. Upon clicking one of the boxes on top, one of the boxes on the bottom hides. How do I make the two boxes on the bottom stay centered?
Here is the landing page:
I want the divs on the bottom centered, once a box is hidden. I want the SharePoint and Teams boxes centered after the other box is hidden.
Center the bottom two div's after change ^
Code:
.margin-bottom-20 {
margin-bottom: 20px;
}
.collabProjects:hover, .collabFiles:hover, .collabSocially:hover {
box-shadow: 0 0 15px rgba(33,3,3,.2);
}
.decisionTreeBox {
background-color: #4B92DB;
color: white;
width: 300px;
height: 140px;
display: flex;
justify-content: center;
align-items: center;
transition: box-shadow .3s;
}
#decisionTreeOneDrive {
background-color: #094AB2;
color: white;
width: 300px;
height: 140px;
display: flex;
justify-content: center;
align-items: center;
}
#decisionTreeSharePoint {
background-color: #008CE7;
color: white;
width: 300px;
height: 140px;
display: flex;
justify-content: center;
align-items: center;
}
#decisionTreeTeams {
background-color: #4A1EBD;
color: white;
width: 300px;
height: 140px;
display: flex;
justify-content: center;
align-items: center;
}
#innerBoxHeadings {
color: white!important;
text-align: center;
padding-top: 5px;
}
#columnMiddleBorderLeft, #pageTitle {
display:none!important;
}
<div class="outer-container">
<div class="row">
<div class="col-md-6" style="text-align: center;">
<div data-collaborate="shareCollab" class="decisionTreeBox" style="font-size: x-large; float: right;">
Share and Collaborate</div>
</div>
<div class="col-md-6" style="text-align: center;">
<div data-collaborate="shareExternally" class="decisionTreeBox" style="font-size: x-large;">
Share Externally</div>
</div>
</div>
<hr />
<div class="container" style="padding: 0px;">
<div class="row">
<a href="/TrainingResourceCenter/O365Training/Pages/OneDrive.aspx">
<div class="col-md-4 margin-bottom-20" style="text-align: center;">
<div data-decision="shareExternally" id="decisionTreeOneDrive">
<h3 id="innerBoxHeadings"><img src="/TrainingResourceCenter/O365Training/PublishingImages/onedrive-logo.png" style="width: 65px; height: 65px; padding-bottom: 5px; padding-right: 10px; vertical-align: middle;" />OneDrive</h3>
</div>
</div>
</a>
<a href="/TrainingResourceCenter/O365Training/Pages/SharePointOnline.aspx">
<div class="col-md-4 margin-bottom-20" style="text-align: center;">
<div data-decision="shareCollab shareExternally" id="decisionTreeSharePoint">
<h3 id="innerBoxHeadings"><img src="/TrainingResourceCenter/O365Training/PublishingImages/SharePointDecisionTree.png" style="padding-bottom: 5px; padding-right: 10px; vertical-align: middle;" />SharePoint</h3>
</div>
</div>
</a>
<a href="/TrainingResourceCenter/O365Training/Pages/Teams.aspx">
<div class="col-md-4 margin-bottom-20" style="text-align: center;">
<div data-decision="shareCollab" id="decisionTreeTeams">
<h3 id="innerBoxHeadings"><img src="/TrainingResourceCenter/O365Training/PublishingImages/TeamsDecisionTree.png" style="padding-bottom: 5px; padding-right: 10px; vertical-align: middle;" />Teams</h3>
</div>
</div>
</a>
</div>
</div>
</div>
<script>
function projectCollab() {
var divsToCange = document.querySelectorAll('[data-decision]'),
attr = this.getAttribute('data-collaborate');
for (var i = 0; i < divsToCange.length; i++) {
var d = divsToCange[i];
if (d.getAttribute('data-decision').includes(attr)) { /* Had: == attr) { */
d.parentNode.style.display = 'block';
} else {
d.parentNode.style.display = 'none';
}
}
return false;
}
var divButtons = document.querySelectorAll('[data-collaborate]');
for (var i = 0; i < divButtons.length; i++) {
divButtons[i].addEventListener('click', projectCollab);
}
</script>
There's an old technique of centering the content of the parent, then making the children display: inline-block;. You will have to account for the visibility of the white-space " " character — but that is pretty well documented (e.g. Remove Whitespace Between Inline-Block Elements). You'll have to play with margin to restore your spacing, AND remember to change the JS to reflect inline-block instead of block when restoring the elements.
In the interest of selector sanity, I added an example class to the containing row element in the code demo.
HTML
<div class="row centered-buttons">
CSS
.centered-buttons {
text-align: center;
}
.centered-buttons a {
display: inline-block;
vertical-align: middle;
}
.margin-bottom-20 {
margin-bottom: 20px;
}
.collabProjects:hover,
.collabFiles:hover,
.collabSocially:hover {
box-shadow: 0 0 15px rgba(33, 3, 3, .2);
}
.decisionTreeBox {
background-color: #4B92DB;
color: white;
width: 300px;
height: 140px;
display: flex;
justify-content: center;
align-items: center;
transition: box-shadow .3s;
}
#decisionTreeOneDrive {
background-color: #094AB2;
color: white;
width: 300px;
height: 140px;
display: flex;
justify-content: center;
align-items: center;
}
#decisionTreeSharePoint {
background-color: #008CE7;
color: white;
width: 300px;
height: 140px;
display: flex;
justify-content: center;
align-items: center;
}
#decisionTreeTeams {
background-color: #4A1EBD;
color: white;
width: 300px;
height: 140px;
display: flex;
justify-content: center;
align-items: center;
}
#innerBoxHeadings {
color: white!important;
text-align: center;
padding-top: 5px;
}
#columnMiddleBorderLeft,
#pageTitle {
display: none!important;
}
.centered-buttons {
text-align: center;
}
.centered-buttons a {
display: inline-block;
vertical-align: middle;
}
<div class="outer-container">
<div class="row">
<div class="col-md-6" style="text-align: center;">
<div data-collaborate="shareCollab" class="decisionTreeBox" style="font-size: x-large; float: right;">
Share and Collaborate</div>
</div>
<div class="col-md-6" style="text-align: center;">
<div data-collaborate="shareExternally" class="decisionTreeBox" style="font-size: x-large;">
Share Externally</div>
</div>
</div>
<hr />
<div class="container" style="padding: 0px;">
<div class="row centered-buttons">
<a href="/TrainingResourceCenter/O365Training/Pages/OneDrive.aspx">
<div class="col-md-4 margin-bottom-20" style="text-align: center;">
<div data-decision="shareExternally" id="decisionTreeOneDrive">
<h3 id="innerBoxHeadings"><img src="/TrainingResourceCenter/O365Training/PublishingImages/onedrive-logo.png" style="width: 65px; height: 65px; padding-bottom: 5px; padding-right: 10px; vertical-align: middle;" />OneDrive</h3>
</div>
</div>
</a>
<a href="/TrainingResourceCenter/O365Training/Pages/SharePointOnline.aspx">
<div class="col-md-4 margin-bottom-20" style="text-align: center;">
<div data-decision="shareCollab shareExternally" id="decisionTreeSharePoint">
<h3 id="innerBoxHeadings"><img src="/TrainingResourceCenter/O365Training/PublishingImages/SharePointDecisionTree.png" style="padding-bottom: 5px; padding-right: 10px; vertical-align: middle;" />SharePoint</h3>
</div>
</div>
</a>
<a href="/TrainingResourceCenter/O365Training/Pages/Teams.aspx">
<div class="col-md-4 margin-bottom-20" style="text-align: center;">
<div data-decision="shareCollab" id="decisionTreeTeams">
<h3 id="innerBoxHeadings"><img src="/TrainingResourceCenter/O365Training/PublishingImages/TeamsDecisionTree.png" style="padding-bottom: 5px; padding-right: 10px; vertical-align: middle;" />Teams</h3>
</div>
</div>
</a>
</div>
</div>
</div>
<script>
function projectCollab() {
var divsToCange = document.querySelectorAll('[data-decision]'),
attr = this.getAttribute('data-collaborate');
for (var i = 0; i < divsToCange.length; i++) {
var d = divsToCange[i];
if (d.getAttribute('data-decision').includes(attr)) { /* Had: == attr) { */
d.parentNode.style.display = 'block';
} else {
d.parentNode.style.display = 'none';
}
}
return false;
}
var divButtons = document.querySelectorAll('[data-collaborate]');
for (var i = 0; i < divButtons.length; i++) {
divButtons[i].addEventListener('click', projectCollab);
}
</script>
In cases like this, I usually conditionally set the class of the content that changes depending on how many items are present. For example, imagine you're checking an array called items that is either 2 or 3 items long. Here is some pseudocode that shows you what I'm thinking.
let itemsClass;
if (items.length === 2) {
itemsClass = 'col-md-6';
} else {
itemsClass = 'col-md-4';
}
myElement.setClass(itemsClass);
You could set a click handler that would check after you click a button or whatever. In react, that could be part of your component render() method.
I don't know what you're using for JS so I won't try to write your code for you. But the gist of it is, decide the class name on the fly with JS and apply it to your elements.
edit: Sorry, I didn't read your entire code snippet. This is something you could add to the handler you already have. You'd just have to grab the elements and alter the classes at that time.
Add the following CSS to the row class:
<div class="container" style="padding: 0px;">
<div class="row" style="justify-content: center">
Since bootstrap uses flexbox system, this should work for you.
What you are asking for is built into BS. But you've muddied the framework by adding html where it ought not be. specifically wrapping BS cols with an anchor tag which breaks the BS grid system, specifically the rule that states only cols can be children of rows.
I've made your html substantially shorter for simplicity and altered your js somewhat to showcase the hiding part. I hope this a decent example that you can expand upon.
FIXES:
I've moved the anchor tab inside the col. This was breaking the alignment of the BS Grid And is also incorrect markup per the BS grid system.
I altered your JS to hide the col, not the anchor. This allows the BS flex grid to properly do it's alignment
In the javascript, consider adding a attribute to your markup such that you don't have to navigate the right number of parent levels. As it stands, if you add more layers to the col html, your JS will break.
function projectCollab() {
var divsToChange = document.querySelectorAll('[data-decision]'),
attr = this.getAttribute('data-collaborate');
for (var i = 0; i < divsToChange.length; i++) {
var d = divsToChange[i];
d.parentNode.parentNode.hidden = ! d.getAttribute('data-decision').includes(attr);
}
return false;
}
var divButtons = document.querySelectorAll('[data-collaborate]');
for (var i = 0; i < divButtons.length; i++) {
divButtons[i].addEventListener('click', projectCollab);
}
.collabProjects:hover,
.collabFiles:hover,
.collabSocially:hover {
box-shadow: 0 0 15px rgba(33, 3, 3, .2);
}
div[data-decision],
div[data-collaborate]{
color: white;
width: 200px;
height: 100px;
}
.decisionTreeBox {
background-color: #4B92DB;
}
#decisionTreeOneDrive {
background-color: #094AB2;
}
#decisionTreeSharePoint {
background-color: #008CE7;
}
#decisionTreeTeams {
background-color: #4A1EBD;
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" integrity="sha384-WskhaSGFgHYWDcbwN70/dfYBj47jz9qbsMId/iRN3ewGhXQFZCSftd1LZCfmhktB" crossorigin="anonymous">
<div class="outer-container">
<div class="container-fluid">
<div class="row justify-content-center">
<div class="col-4">
<div data-collaborate="shareCollab" class="decisionTreeBox">
Share and Collaborate</div>
</div>
<div class="col-4">
<div data-collaborate="shareExternally" class="decisionTreeBox">
Share Externally</div>
</div>
</div>
<hr />
<div class="row justify-content-center">
<div class="col-4">
<a href="#">
<div data-decision="shareExternally" id="decisionTreeOneDrive">
<h3 id="innerBoxHeadings">OneDrive</h3>
</div>
</a>
</div>
<div class="col-4">
<a href="#">
<div data-decision="shareCollab shareExternally" id="decisionTreeSharePoint">
<h3 id="innerBoxHeadings">SharePoint</h3>
</div>
</a>
</div>
<div class="col-4">
<a href="#">
<div data-decision="shareCollab" id="decisionTreeTeams">
<h3 id="innerBoxHeadings">Teams</h3>
</div>
</a>
</div>
</div>
</div>
</div>