How to create equal spacing between the line elements - html

Below is the HTML code for my angular JS web app:
<div class="choice" >
<br> <br>
<ul>
<li class="players" ng-repeat="player in players">
<img ng-src="{{player.image}}"><br><br>
<span class="glyphicon glyphicon-user"></span> {{player.name}} <br>
<span class="glyphicon glyphicon-flag"></span> {{player.Team}} <br>
<span class="glyphicon glyphicon-tag"></span>₦{{player.price}} <br>
<span class="glyphicon glyphicon-knight"></span>{{player.position| uppercase }}<br>
<span class="glyphicon glyphicon-info-sign"></span>{{player.Status}}
<br>
<button class="btn btn-secondary btn-sm" ng-class="{'btn-danger': history.indexOf(player) >= 0 }" ng-click="buy(player)">{{history.indexOf(player)>=0?'REMOVE':'SELECT'}}</button>
</li>
</ul>
<br><br>
<button type="submit" class="btn btn-lg btn-primary btn-md " ng-disabled="history.length<6" ng-disabled="getTotal<0" ng-click="saveTeam()" > Save Team </button>
<br><br>
</div>
And below is the CSS:
.choice{
background: white;
color: #333;
font-size: 13px;
}
.choice ul {
list-style: none;
}
.choice img {
max-height: 100px;
max-width: 65px;
margin-top: 7px;
}
.players{
display: inline-table;
float: left;
text-align: left;
}
MY ISSUE:
The Issue i have is that the spacing in between the line elements is not consistent between the list elements. Depending on the length of the name a player, the space between one player and the next is displayed inconsistently. I had hopes that using the flex: left; would solve this but it does not. Is there a way to achieve equal spacing between the list elements ?

use ulClass class in your <ul> tag. and its css as below
.ulClass{
display: flex;
flex-direction: column;
justify-content: space-between;
}

Related

Aligning buttons with CSS

So basically I've been trying to center align two buttons on my website, and literally none of the common methods worked. It doesn't move no matter what, and nothing else is overriding it. I may be missing something but this is such a headache.
My CSS button code:
.btn {
border-radius: 10px !important;
font-size: 16px !important;
font-weight: 600 !important;
text-transform: uppercase !important;
}
.btn-primary {
background-color: #346cfc !important
}
.btn-secondary {
background-color: #346cfc !important;
}
My HTML code:
</nav>
<div class="heading">
<h1 class="display-5 title"></i>Ricky</h1>
<p class="subtitle">Ricky is a multi purpose bot with features like Music, Economy, Utility, and more!<br />Check out the docs or get started below.</p>
<a class="btn btn-primary btn-lg text-center"href="https://discord.com/oauth2/authorize?client_id=778817321640394762&scope=bot&permissions=2147483647" target="_blank" role="button">Invite</a>
<a class="btn btn-secondary btn-lg text-center"href="https://discord.gg/XXBpY2v6AU" target="_blank" role="button">Support Server</a>
<br /><br /><br /><br /><br /><br />
I did find something that worked, making the position relative worked. But it looks bad on mobile depending on what I set the top and left % as
.btn-primary {
position: relative;
top: 50%;
left: 50%;
background-color: #7289DA !important
}
Any better way to do this than just making it look bad on PC or mobile?
You should wrap your button to a div
<div class="wrapper">
<a class="btn btn-primary btn-lg text-center"href="https://discord.com/oauth2/authorize?client_id=778817321640394762&scope=bot&permissions=2147483647" target="_blank" role="button">Invite</a>
<a class="btn btn-secondary btn-lg text-center"href="https://discord.gg/XXBpY2v6AU" target="_blank" role="button">Support Server</a>
</div>
.wrapper {
display: "flex";
align-items: "center";
}
https://css-tricks.com/almanac/properties/a/align-items/

Two buttons in a div are misaligned

The second button in a div is always lower than the first one across the entire project. The two buttons are have the same height: 30px. Code:
<div>
<button class="btn btn-secondary action btn-sm" (click)=navigateToDetails(financialPlatform.publicIdentifier)>
{{ 'general.button.details' | translate }}
</button>
<button class="btn btn-secondary action btn-sm" (click)="navigateToPlatforms(financialPlatform.publicIdentifier)">
{{'financial.institutions.overview.button.platforms' | translate}}
</button>
</div>
Two misaligned buttons
If I have three buttons, the second and third one are aligned but are slightly lower than the first one.
Edit with css and more code:
CSS:
button {
margin: 2px;
font-size: 12px !important;
}
.btn-primary {
background-color: darkslategrey !important;
border: none;
}
.btn-secondary {
background-color: darkblue !important;
border: none;
}
<tbody>
<tr *ngFor="let financialPlatform of financialInstitutionsPage.content | paginate: financialInstitutionsPage">
<td>{{financialPlatform.name}}</td>
<td>{{financialPlatform.code}}</td>
<td>{{financialPlatform.country}}</td>
<td>{{financialPlatform.aisStatus | apiStatus | translate}}</td>
<td>{{financialPlatform.pisStatus | apiStatus | translate}}</td>
<td>{{financialPlatform.provider}}</td>
<td>
<div>
<button class="btn btn-secondary action btn-sm" (click)=navigateToDetails(financialPlatform.publicIdentifier)>
{{ 'general.button.details' | translate }}
</button>
<button class="btn btn-secondary action btn-sm" (click)="navigateToPlatforms(financialPlatform.publicIdentifier)">
{{'financial.institutions.overview.button.platforms' | translate}}
</button>
</div>
</td>
</tr>
</tbody>
The above is just a table with one actions column that includes two buttons, but my problem is in the entire project.
To ensure the child <button> elements nested in the parent <div> are aligned vertically, you can make the parent container a flexbox and use align-items: center so the flex items margin boxes are centered within the line on the cross axis.
.parent {
display: flex;
align-items: center;
}
.parent button {
margin: 2px;
font-size: 12px !important;
}
.btn-primary {
background-color: darkslategrey !important;
border: none;
}
.btn-secondary {
background-color: darkblue !important;
border: none;
}
<head>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
</head>
<tbody>
<tr *ngFor="let financialPlatform of financialInstitutionsPage.content | paginate: financialInstitutionsPage">
<td>
<div class="parent">
<button class="btn btn-secondary action btn-sm" (click)=navigateToDetails(financialPlatform.publicIdentifier)>Details</button>
<button class="btn btn-secondary action btn-sm" (click)="navigateToPlatforms(financialPlatform.publicIdentifier)">Platforms</button>
</div>
</td>
</tr>
</tbody>

Set fixed divs regardless of the size of the content

I'm developing an item list that is filled dinnamically with some data that is getting from a controller.
I had a problem when the data is shown because I need to show it into two columns (called "record_left_content" and "record_right_content"), but when the obtained text is too long, the two columns are merged into one.
Someone knows how to positionate the both colums in a fixed way regardless of the size of the text/content ?
Code:
<div class="col-lg-9" id="middle_column">
<div class="text-center text-muted" t-if="not education_timetable_ids">
<h1>No timetables found</h1>
</div>
<div class="text-center text-muted" t-else="">
<ul class="list-unstyled">
<li t-foreach="education_timetable_ids" t-as="timetable" t-attf-class="media">
<div itemscope="itemscope" class="media-body" itemtype="https://schema.org/learningResourceType" >
<h4>
<a t-attf-href="/" itemprop="url" onclick="return false"><span itemprop="schedule"><t t-esc="timetable.display_name" /> </span></a>
</h4>
<div id="record_left_content">
<div>
<span t-if="timetable.academic_year_id" class="badge badge-info">
<i class="fa fa-clock-o" role="img" aria-label="Academic year" title="Academic year"></i>
Academic year:
<t t-esc="timetable.academic_year_id.name" />
</span>
//more code
<div id="record_right_content">
//more code
</div>
.media {
padding: 10px;
background-color: #e9ecef;
border-radius: 0.25rem;
margin: 10px;
}
#record_left_content {
float: left;
margin-left: 20%;
}
#record_right_content {
float: right;
margin-right: 20%;
}
Thanks for reading!

Dropdown menu doesn't view its items

I want to create a drop down menu, when i click the glyphicon the down arrow, it should view the drop down menu which has these items [Messages, log out, etc..].
However when i click it nothing appears at all, what is missing here?
//Html File:
<html>
<!-- Head -->
<head>
<!-- Bootstrap -->
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="css/bootstrap-theme.min.css" rel="stylesheet">
<link href="css/font-awesome.min.css" rel="stylesheet">
<link href="css/bootstrap-social.css" rel="stylesheet">
<link href="css/style.css" rel="stylesheet">
</head>
<!-- Body -->
<body>
<div class="navbar">
<i class="fa fa-home"></i> Marble
<a class="left"> <i onclick="myFunction(this)" class=" fa fa-bell" ></i> Notifications </a>
<a class="left user"> <i class=" fa fa-user-circle"> </i> User </a>
<div class="dropdown">
<a class="editClass dropdown-toggle" data-toggle="dropdown" > <span class=" glyphicon glyphicon-menu-down"></span> </a>
<ul class="dropdown-menu"> //when i remove class="dropdown-menu", the items appears but the drop down is gone, and when i add them back, the items are not shown when i click the drop down icon.
<li> <a> <i class="fa fa-envelope-o"></i> Messages </a> </li>
<li role="separator" class="divider"></li>
<li> <a> <i class="fa fa-hourglass-3"></i> Timeline </a> </li>
<li role="separator" class="divider"></li>
<li> <a> <i class="fa fa-cog"></i> Settings </a> </li>
<li role="separator" class="divider"></li>
<li> <a> <span class="glyphicon glyphicon-log-out"></span> Log Out </a> </li>
<li role="separator" class="divider"></li>
</ul>
</div>
</div>
<div>
<img src="Diagram.png" alt="diagram" width="400" height="300">
</div>
<div>
<p id="sentence"> "You don't have any projects" </p>
<button onclick="createProject()" class="button1 btn btn-lg"> <b> Add Project </b> </button>
</div>
<div>
<form class="form-popup" id="projects">
<h2 align="center"> <span class="glyphicon glyphicon-th"></span> New Project </h2>
<input type="text" placeholder="Project Name" required> <br>
<textarea placeholder="Project Description" required=""></textarea> <br>
<p> Start Date: </p>
<p> End Date: </p>
<input type="Date" name="start Date" required="">
<input type="Date" name="End Date" required="">
<h2 align="center"> <span class="glyphicon glyphicon-book"> </span> References </h2>
<div id="refTextBoxes">
<input type="text" placeholder="Add Reference" required> <br>
</div>
<button onclick="addRef()"> Add another </button> <br>
<button type="submit" onclick="hideAndAdd()" > Done </button>
<!-- class="btn" bt3ml el button shakl kda 7elw -->
</form>
</div>
<script>
function myFunction(x)
{
x.classList.toggle("fa-bell-slash");
}
function createProject()
{
document.getElementById("projects").style.display = "block";
}
function addRef()
{
var totalTextBoxes = document.getElementsByClassName("input_text");
totalTextBoxes = totalTextBoxes.length + 1;
document.getElementById("refTextBoxes").innerHTML=document.getElementById("refTextBoxes").innerHTML+
"<input type='text' class='input_text' id='input_text"+totalTextBoxes+"' placeholder='Add Reference' + required> <br>";
}
function hideAndAdd()
{
var x = document.getElementById("sentence");
x.style.display = "none";
}
</script>
</body>
<!-- Closing of html tag -->
</html>
//Css File:
body
{
font-family: Arial, Helvetica, sans-serif;
/* background-color: #ABB1BA; */
}
.form-popup
{
display: none;
}
/* Style the navigation bar */
.navbar
{
width: 100%;
background-color: #877ebf;
overflow: auto;
}
/* Navbar links */
.navbar a
{
float: left ;
text-decoration: none;
color: #CCCCCC;
font-size: 17px;
padding: 12px;
}
/* Navbar links on mouse-over */
.navbar a:hover, i:hover, span:hover
{
background-color: #555;
cursor: pointer;
}
img
{
display: block;
margin-left: auto;
margin-right: auto;
}
p
{
text-align: center;
font-family: "Arial Black", Gadget, sans-serif;
font-size: 20px;
}
button
{
text-align: center;
font-size: 16px;
margin: 25px 475px;
cursor: pointer;
}
.button1
{
background-color: #CCCCCC;
color: #333333;
border: 4px solid #877ebf;
}
/*
.navbar i.editClass, span.editClass
{
float: right;
}
*/
.left
{
position: absolute;
right:135;
}
.user
{
/*margin: 25px 25px; */
/*float: right;
padding: 100px; */
position: absolute;
right:40;
}
.editClass
{
position: absolute;
right:5;
}
/* Add responsiveness - will automatically display the navbar vertically instead of horizontally on screens less than 500 pixels */
#media screen and (max-width: 500px) {
.navbar a {
float: none;
display: block;
}
}
I'm using here Bootstrap, html, and css.
I think there is problem in the css file, but i can't manage to find where exactly.
You have overflow effectively hidden on your navbar. Remove that.
.navbar {
/* overflow: auto; */
}
Demo
You'll want to get familiar with your browser's document inspector. It'll make diagnosing things like this almost effortless.

Making a div responsive

I am trying to get a make a div which contains a set of tools responsive.I have a side menu below this which I have made responsive. Could someone let me know where would this be wrong.
#tools {
width: 160px;
position: fixed;
display: inline-block;
margin: 0 auto;
line-height: 1.4em;
}
#media only screen and (max-width: 600px) {
#tools {
width: 70%;
}
}
<div id="tools" style="width: 100%">
<table>
<tr>
<td>
<input type="text" id="searchInput" placeholder="Type To Filter" ng-model="search" class="searchMenu">
</td>
<td id=uploadedit>
<button id="upload" onclick="insertIntoDatabase()" class="pinColor"><i class="fa fa-upload fa-2"></i>
</button>
</td>
<td id=impledit>
<button id="implview" onclick="openImplView()" class="pinColor"><i class="fa fa-pencil fa-2"></i>
</button>
</td>
<td>
<button id="home" class="homeButton"><i class="fa fa-home fa-2"></i>
</button>
</td>
<td>
<button id="keep-menu-open" class="pinColor" ng-click="openAndFixMenu"><i class="pinColor"></i>
</button>
</td>
<td>
<button id="open-left" class="toggleButton" ng-click="toggleMenu()"> <i class="fa fa-bars fa-2"></i>
</button>
</td>
</tr>
</table>
</div>
You have a typo in your media query: it should be # instead of ##. Aside from that, you're declaring width: 100% inline which overwrites whatever you've written in a stylesheet, which is why you don't see the result of the query.
Probably best to take the style="100%" from the div, any inline style like this will over-ride whatever is in the stylesheet.
Also in the media query you have
##tools { width: 70%; }
change to
#tools { width: 70%; }