I have a problem making my grid system work, my containers are stacking up under each other instead of being a grid system of 3 rows.
I have this styling on:
.container {
display: grid;
margin: auto;
width: 65%;
grid-template-columns: repeat(3, 1fr);
grid-gap: 0rem;
justify-items: center;
}
.topic {
position: relative;
width: 350px;
height: 170px;
border: 1px solid rgb(214, 214, 214);
background: white;
padding: 1rem;
text-align: left;
border-radius: 10px;
cursor: pointer;
color: black;
box-shadow: 2px 1px 1px 1px rgb(228, 228, 228);
hr {
color: white;
text-decoration: none;
}
h3 {
color: black;
padding-bottom: 4%;
}
p {
color: black;
padding-top: 20px;
}
#count {
position: absolute;
bottom: 5%;
right: 5%;
font-size: 13px;
}
}
With this html
<template>
<div class="container">
<router-link to="/">
<div class="topic" v-for="topic in topics" :key="topic.id">
<h3>{{ topic.description }}</h3>
<hr />
<p id="count">Completed: 0/17</p>
</div>
</router-link>
</div>
</template>
I had it all working before I decided to put a router-link around my container, so that's the root of my problem, but I would of course like to keep it this way and not having a small link inside.
You are iterating your <div> element inside the <router-link> element, so they are all ending up inside the first column. Forgive me if this is not possible as I am not very familiar with Vue, but couldn't you just
<template>
<div class="container">
<router-link to="/" v-for="topic in topics" >
<div class="topic" :key="topic.id">
<h3>{{ topic.description }}</h3>
<hr />
<p id="count">Completed: 0/17</p>
</div>
</router-link>
</div>
</template>
If your problem is the router-link you can try this:
<template>
<div class="container">
<router-link tag="div to="/" v-for="topic in topics" class="topic" :key="topic.id">
<h3>{{ topic.description }}</h3>
<hr />
<p id="count">Completed: 0/17</p>
</router-link>
</div>
</template>
Related
(apologies for my English in advance)
Hello, I want to put the display of a jinja for loop side by side, but I can't seem to know how to do it (new to flask)
Here's how it is being displayed on my website
And here is a basic idea of how I want it to be displayed
Here is the HTML code
{% for item in user.people %}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<div class="container">
<div class="card" style="margin-top: 100px;" >
<div class="image">
<img src="{{ url_for('static', filename='profile_pics/'+item.image) }}" alt="zul" style="background-color: #eee; margin-left: 240px; height: 130px; border-radius: 80px;">
</div>
<div style="margin-top: -120px;" class="data">
<div class="title">
<h1 class="auth">{{item.first_name}} {{ item.last_name }}</h1>
<h2> {{item.email}} </h2>
</div>
<div class="content">
<div class="social">
<strong>Company: </strong>{{item.company}}
</div>
<div class="social">
<strong>Address: </strong>{{ item.address }}
</div>
<div class="social">
<button type="button" id="delete" class="btn btn-outline-danger" onClick="deletePerson( {{ item.id }} )">Remove</button>
</div>
</div>
Here is the CSS
#dropdownMenuLink {
position:absolute;
top:-80px;
right:-190px;
background-color: #0275d8
;
}
#delete {
width: auto;
height: auto;
margin-left: -5px;
border-radius: 12px;
}
.card {
position: relative;
margin: 150px auto;
width: 400px;
flex: 1 1 0px;
padding: 10px;
box-shadow: 3px 10px 20px rgba(0, 0, 0, 0.2);
border-radius: 12px;}
.content {
margin-top: 25px;
display: flex;
flex-direction: column;
}
.auth {
font-size: 34px;
font-weight: bold;
margin-bottom: 0;
}
h2 {
font-size: 18px;
letter-spacing: 0.5px;
font-weight: 300;
}
.company {
margin-bottom: 5px;
}
.address {
margin-bottom: 5px;
}
.remove {
margin-bottom: 5px;
}
a {
text-decoration: none !important;
color: black;
margin-left: 8px;
font-weight: 300;}
i {
font-weight: 400;
color: red;
}
.location {
display: flex;
flex-direction: column; }
p {
font-weight: 300;
}
Anyone can help me please
could someone help me on this, thanks
I'm trying to create the layout identical to figure 2, but I'm not able to ...
How could i do a layout like the figure 2 using flex.
I create a board using flex but the items are not placed in correct way,
and i'm struggling to add a second line.
So far what I've managed to do is the following,
.collection-card {
display: flex;
flex-direction: row;
justify-content: space-between;
flex-grow: 5;
flex-shrink: 5;
min-width: 50em;
max-width: 50em;
margin: 15px !important;
}
.grid-row-container {
display: grid;
grid-template-rows: auto auto;
}
.grid-container {
display: grid;
grid-template-columns: auto auto auto;
// padding: 10px;
}
.grid-item {
//background-color: rgba(255, 255, 255, 0.8);
border: 1px solid rgba(0, 0, 0, 0.8);
// padding-left: 5px;
// padding-right: 5px;
// font-size: 30px;
text-align: center;
}
.my-row {
display: flex;
}
.my-column {
flex: 50%;
}
<Card className='collection-card' interactive={true} onClick={() => history.push(getPath())}>
{/* my-row */}
<div className='tx-inverse tx-bold collection-title'>{name}</div>
<div className='grid-row-container '>
<div className='grid-container'>
<div className='grid-item'>ykykysdfsdfsdafsdfasdfsdf k</div>
<div className='grid-item'>aaaaaa k</div>
<div className='grid-item'>
<div className='collection-card-buttons '>
<button
type='button'
className='btn btn-primary icon-button field-inline card-forcewidth'
onClick={() => {
//setEntityModalOpen(true);
// history.push(`/objects/object-templates/${id}` + window.location.search);
}}
>
view
</button>
</div>
</div>
</div>
<div className='grid-container'>
<div className='grid-item'>aaaaaa k</div>
<div className='grid-item'>aaaaaa k</div>
</div>
</div>
</Card>
and ends up like this:
but what i need is the items placed like this,
In order to share the potential solution, I had to re-write the code to work with plain HTML/CSS. There is no right way to solve the layout issue but I have used flexbox and aligned the elements accordingly to achieve the desired layout. With this example, you should be able to recycle the CSS and add it to your specific project to work. Run the code snippet below and hope it helps!
p {
margin: 0;
padding: 0;
display: inline;
}
.user-container {
max-width: 750px;
border: 1px solid #545454;
border-radius: 15px;
margin: 0 auto;
padding: 2rem;
font-family: Arial, Helvetica, sans-serif;
}
.user-title {
display: block;
font-size: 1rem;
font-weight: 700;
margin: 0;
padding-bottom: 2rem;
}
.user-item {
display: flex;
flex-direction: row;
flex-wrap: wrap;
padding: 1rem;
margin-bottom: 1rem;
border: 1px solid #545454;
border-radius: 15px;
font-size: 12px;
color: #6f6d6d;
}
.btn {
font-weight: 700;
line-height: 1;
font-size: 1rem;
text-transform: none;
padding: 10px 30px;
border: 1px solid #222222;
border-radius: 15px;
text-decoration: none;
color: #fff;
background-color: #222222;
}
.user-item__primary-button {
color: #fff;
background-color: #222222;
}
.user-item__secondary-button {
color: #222222;
background-color: transparent;
}
.w-50 {
width: 50%;
}
.text-ar {
text-align: right;
}
.align-center {
align-self: center;
}
.align-end {
align-self: end;
}
.pb-1 {
padding-bottom: 1rem;
}
.mr-1 {
margin-right: 1rem;
}
<section class="user-container">
<p class="user-title">Users List</p>
<div class="user-item">
<p class="user-item__email w-50 align-center">John Doe (john.doe#gmail.com)
<p>
<div class="w-50 text-ar align-center">
<p class="user-item__role mr-1">Admin</p>
<button class="user-item__primary-button btn">Button</button>
<button class="user-item__secondary-button btn">Button</button>
</div>
<div class="w-50">
<button class="user-item__secondary-button btn">Button</button>
</div>
<p class="user-item__detail w-50 text-ar align-end">Added Dec 01 2021 by Jane Doe</p>
</div>
<div class="user-item">
<p class="user-item__email w-50 align-center">John Doe (john.doe#gmail.com)
<p>
<div class="w-50 text-ar align-center">
<p class="user-item__role mr-1">Admin</p>
<button class="user-item__primary-button btn">Button</button>
<button class="user-item__secondary-button btn">Button</button>
</div>
<div class="w-50">
<button class="user-item__secondary-button btn">Button</button>
</div>
<p class="user-item__detail w-50 text-ar align-end">Added Dec 01 2021 by Jane Doe</p>
</div>
</section>
how i want it to look like
how it looks right now
.row2 {
display: flex;
justify-content: space-evenly;
align-items: stretch;
}
.til-col {
flex-basis: 32%;
border: 7px solid #c9c9c9;
border-radius: 30px;
margin: 10px;
position: relative;
overflow: hidden;
padding: 40px;
box-shadow: 5px 5px 20px rgba(92, 91, 91, 0.2);
flex-direction: column;
align-items: center;
}
.til-col img {
width: 50%;
border-radius: 10px;
padding-bottom: 5%;
}
.button {
display: inline-block;
text-decoration: none;
color: #fff;
margin: 12px 34px;
border-radius: 10px;
font-size: 13px;
padding: 0 20px;
background: #012a5d;
position: relative;
cursor: pointer;
}
<div class="row2">
<div class="til-col">
<img src="images/Home/Layer 2-2.svg">
<p>Interact with a TIL timeline showing key moments and events over the years</p>
<a href="classroom.html" class="button">
<h3>TIL Story</h3>
</a>
</div>
<div class="til-col">
<img src="images/Home/Progress.svg">
<p>Discover projects and initiatives that have launched out of TIL to support innovation in learning spaces</p>
<a href="classroom.html" class="button">
<h3>Projects</h3>
</a>
</div>
<div class="til-col">
<img src="images/Home/Report_icons-02 1.svg">
<p>See the transformation of classroom spaces and follow progress over stages of the redesign process</p>
<a href="classroom.html" class="button">
<h3>Classroom Redesign</h3>
</a>
</div>
</div>
I want to make the image of each box aligned with each other, same with the text and the button, like it is presented in the image. Yet everything would follow right after the image, the text ends. I also want to uniform the size of the image, without messing up the proportion, but I don't know how to do so.
Simply adding the below styles to ".til-col" class will achieve the expected result
display: flex;
text-align: center;
Maybe something like this?
P.S. I don't think CSS have something to let you horzionally align several child elements from different blocks.
.row2 {
display: flex;
justify-content: space-evenly;
align-items: stretch;
}
.til-col {
display:flex;
flex-basis: 32%;
border: 7px solid #c9c9c9;
border-radius: 30px;
margin: 10px;
position: relative;
overflow: hidden;
padding: 40px;
box-shadow: 5px 5px 20px rgba(92, 91, 91, 0.2);
flex-direction: column;
align-items: center;
}
.til-col img {
width: 50%;
border-radius: 10px;
padding-bottom: 5%;
}
.til-col > p{
padding-bottom:40px;
}
.button {
display: inline-block;
text-decoration: none;
color: #fff;
margin: 12px 34px;
border-radius: 10px;
font-size: 13px;
padding: 0 20px;
background: #012a5d;
position: absolute;
bottom:20px;
cursor: pointer;
}
<div class="row2">
<div class="til-col">
<img src="images/Home/Layer 2-2.svg">
<p>Interact with a TIL timeline showing key moments and events over the years</p>
<a href="classroom.html" class="button">
<h3>TIL Story</h3>
</a>
</div>
<div class="til-col">
<img src="images/Home/Progress.svg">
<p>Discover projects and initiatives that have launched out of TIL to support innovation in learning spaces</p>
<a href="classroom.html" class="button">
<h3>Projects</h3>
</a>
</div>
<div class="til-col">
<img src="images/Home/Report_icons-02 1.svg">
<p>See the transformation of classroom spaces and follow progress over stages of the redesign process</p>
<a href="classroom.html" class="button">
<h3>Classroom Redesign</h3>
</a>
</div>
</div>
You can follow below code for solution
.row2 {
display: flex;
justify-content: space-evenly;
align-items: stretch;
}
.til-col {
flex-basis: 32%;
border: 7px solid #c9c9c9;
border-radius: 30px;
margin: 10px;
position: relative;
overflow: hidden;
padding: 40px;
box-shadow: 5px 5px 20px rgba(92, 91, 91, 0.2);
flex-direction: column;
align-items: center;
display: flex;
justify-content: space-between;
text-align: center;
}
.til-col img {
width: 50%;
border-radius: 10px;
}
.icon{
display: flex;
align-items: center;
justify-content: center;
height: 150px;
margin-bottom: 30px;
}
.button {
display: inline-block;
text-decoration: none;
color: #fff;
margin: 34px 0 0 0;
border-radius: 10px;
font-size: 13px;
padding: 0 20px;
background: #012a5d;
position: relative;
cursor: pointer;
}
<div class="row2">
<div class="til-col">
<div class="til-col-head">
<div class="icon"><img src="https://dynamic.brandcrowd.com/asset/logo/2a056b05-ac9b-404f-a619-eba59f92ef48/logo-search-grid-1x?v=637631474641000000"></div>
<p>Interact with a TIL timeline showing key moments and events over the years</p>
</div>
<a href="classroom.html" class="button">
<h3>TIL Story</h3>
</a>
</div>
<div class="til-col">
<div class="til-col-head">
<div class="icon"><img src="https://cdn-icons-png.flaticon.com/512/109/109733.png"></div>
<p>Discover projects and initiatives that have launched out of TIL to support innovation in learning spaces</p>
</div>
<a href="classroom.html" class="button">
<h3>Projects</h3>
</a>
</div>
<div class="til-col">
<div class="til-col-head">
<div class="icon"><img src="https://miro.medium.com/max/1268/0*2pi-PJAAVse41Ovk.png"></div>
<p>See the transformation of classroom spaces and follow progress over stages of the redesign process</p>
</div>
<a href="classroom.html" class="button">
<h3>Classroom Redesign</h3>
</a>
</div>
</div>
As you can see from the title I want to know how to position this menu that I will show to you like on this UI design that I have made.
Here is the examples:
And here is how I tried to do it.
This is the code so far:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="styles.css">
<link href="https://fonts.googleapis.com/css2?family=Inter:wght#300&display=swap" rel="stylesheet">
<title>Document</title>
</head>
<body>
<div class="root flexbox">
<div class="navbar flexbox">
<div class="container flexbox align-center">
<img src="Slike/logo-avion.png" alt="">
<div class="right-column flexbox align-center">
<div class="navbar__navigation">
Početna
Destinacija
O nama
Partner
</div>
<div class="order-btn flexbox align-center">
Prijavi se!
</div>
<div class="konj flexbox align-center">
Registriraj se!
</div>
</div>
</div>
</div>
<div class="content">
<div class="container flexbox">
<div class="content__left_column">
<h2>Ostvarite svoje
putovanje iz snova!</h2>
<p>Potraži svoj odmor na pravom mjestu!</p>
<div class="linija">
<span class="linija crna-linija"></span>
</div>
<div class="kvadrati">
<div class="kvadrati prvi flexbox align-center ">
<p>Lokacija</p>
<img src="Slike/Vector.png" alt="">
</div>
<div class="kvadrati drugi flexbox align-center ">
<p>Aktivnost</p>
<img src="Slike/Vector.png" alt="">
</div>
<div class="kvadrati treci flexbox align-center ">
<p>Ocjena</p>
<img src="Slike/Vector.png" alt="">
</div>
<div class="kvadrati cetvrti flexbox align-center">
<p>Datum</p>
<img src="Slike/Vector.png" alt="">
</div>
</div>
</div>
<div class="content__right_column">
<img src="Slike/template_3_-_copy_dribble1dribble_1.png" alt="">
</div>
</div>
</div>
</div>
</body>
</html>
The div class kvadrati is used to make this menu. I know this may seem complicated to describe but I hope you know what I meant by asking this question. I tried using flexbox display and grid still failed. I am not a beginner in CSS but clearly this is something that I have a problem with.
Here is the CSS code:
.prvi {
width: 22rem;
height: 5.2rem;
border-radius: 0.6rem;
border: 0.1rem solid #afb0b9;
}
EDIT: Here is all of the styles.css
html {
font-size: 10px;
}
* {
margin: 0;
padding: 0;
font-family: Inter;
}
.right-column {
margin-left: auto;
}
body {
background-color: #ffffff;
line-height: 3rem;
}
.container {
width: 1300px;
margin: auto;
}
.root {
font-size: 1.2rem;
flex-direction: column;
min-height: 100%;
}
.flexbox {
display: flex;
}
.align-center {
align-items: center;
}
a {
text-decoration: none;
}
html, body {
height: 100%;
}
.navbar {
margin-top: 20px;
}
.navbar__navigation a {
color: #b8becd;
display: inline-flex;
font-size: 1.5rem;
font-weight: 400;
margin-right: 20px;
}
.order-btn {
height: 4.4rem;
margin-left: 50px;
border-radius: 0.8rem;
border: 0.1rem solid #57d2a3;
margin-right: 15px;
}
.order-btn a {
padding: 21px 24px;
}
.navbar__navigation .active {
color: #202336;
}
.konj {
height: 4.4rem;
border-radius: 0.8rem;
background-color: #57d2a3;
}
.konj a {
color: #ffffff;
padding: 21px 24px;
}
.content__left_column {
margin-left: 20px;
margin-top: 200px;
}
.content__right_column {
margin-top: 90px;
margin-left: auto;
}
.content__left_column h2 {
width: 55.9rem;
color: #202336;
font-family: "Playfair Display";
font-size: 6.4rem;
font-weight: 700;
line-height: 8rem;
}
.content__left_column p {
margin-top: 69px;
width: 40rem;
color: #202336;
font-size: 2.2rem;
font-weight: 400;
}
.linija {
margin-top: 21px;
width: 3.2rem;
height: 0.3rem;
border-radius: 0.4rem;
background-color: #202336;
}
.kvadrati {
margin-top: 20px;
display: grid;
grid-template: 70px 70px / 226px 226px;
width: 226px;
height: 52px;
grid-gap: 20px;
padding: 16px;
}
.kvadrati div {
border-radius: 10px;
border: 1px solid gray;
}
A couple issues with your code
<div class="kvadrati">
<div class="kvadrati prvi flexbox align-center ">
<p>Lokacija</p>
<img src="Slike/Vector.png" alt="">
</div>
<div class="kvadrati drugi flexbox align-center ">
<p>Aktivnost</p>
<img src="Slike/Vector.png" alt="">
</div>
<div class="kvadrati treci flexbox align-center ">
<p>Ocjena</p>
<img src="Slike/Vector.png" alt="">
</div>
<div class="kvadrati cetvrti flexbox align-center">
<p>Datum</p>
<img src="Slike/Vector.png" alt="">
</div>
</div>
As you can see both the grid div <div class="kvadrati"> and the items <div class="kvadrati drugi flexbox align-center "> share the same class kvadrati. As a result they both create a 2x2 grid. You should remove the kvadrati class on the 4 grid items.
.content__left_column p {
margin-top: 69px;
width: 40rem;
color: #202336;
font-size: 2.2rem;
font-weight: 400;
}
And in this part of the code you give the <p> elements a margin-top: 69px;. This causes the <p> Items in your grid to move down 69 pixels. You could change <p>Potraži svoj odmor na pravom mjestu!</p> to a <h3> style it using a class so it doesn't affect the other <p> elements.
Alternatively, since you probably want a dropdown list, you can avoid this by using <select> tags instead. See here for a guide on creating a custom select.
-----------
Here is a simple example on how to use a grid to create a 2x2.
If you need more information on how to use css grid, read on w3schools or MDN
body {
margin: 0;
height: 80vh;
width: 80vw;
}
.grid {
display: grid;
grid-template: 1fr 1fr / 1fr 1fr;
width: 100%;
height: 100%;
grid-gap: 16px;
padding: 16px;
}
.grid div {
border-radius: 10px;
border: 1px solid gray;
}
<div class="grid">
<div></div>
<div></div>
<div></div>
<div></div>
</div>
Is there a way to centralize text inside a bordered element?
When I do border at the element, maybe because its content size is reduced, it gets decentralized.
.circle {
width: 22px;
height: 22px;
border-radius: 50%;
border: solid #00b0ff 1px;
color: #00b0ff;
}
.button-styling {
color: #00b0ff;
font-size: x-large;
}
.outline-h {
outline: thin;
outline-color: blue;
outline-style: solid;
}
<div style="max-width: 15px;">
<h3> With border </h1>
<div class="circle">
<mat-icon class="button-styling">+</mat-icon>
</div>
</div>
<div style="max-width: 15px;">
<h3> Without border </h1>
<div class="outline-h">
<mat-icon class="button-styling">+</mat-icon>
</div>
</div>
You can use flexbox to center the text element:
.circle {
width: 22px;
height: 22px;
border-radius: 50%;
border: solid #00b0ff 1px;
color: #00b0ff;
/*Add*/
display: flex;
justify-content: center;
align-items: center;
}
<div style="max-width: 15px;">
<h3>With border</h3>
<div class="circle">
<mat-icon class="button-styling">+</mat-icon>
</div>
</div>
You could try this:
.circle {
text-align: center;
line-height: 20px;
}
I was able to center it using display: flex.
Check it's browser support though: https://caniuse.com/#feat=flexbox
.circle {
width: 22px;
height: 22px;
border-radius: 50%;
border: solid #00b0ff 1px;
color: #00b0ff;
display: flex;
justify-content: center;
align-items: center;
}
.button-styling {
color: #00b0ff;
font-size: x-large;
}
.outline-h {
outline: thin;
outline-color: blue;
outline-style: solid;
}
<div style="max-width: 15px;">
<h3> With border </h1>
<div class="circle">
<mat-icon class="button-styling">+</mat-icon>
</div>
</div>
<div style="max-width: 15px;">
<h3> Without border </h1>
<div class="outline-h">
<mat-icon class="button-styling">+</mat-icon>
</div>
</div>