Stack objects as a multiple item selector with html and css - html

I have a list of words that I want to stack in columns in order to save and use the left place in an html file for a Django project:
I'm not very good at web development, feel free to explain to me like a 10 year old if I do anything wrong.
{% extends "todo/base.html" %}
{% block content %}
<style>
.elements {
display: block;
}
ul.items {
display: flex;
margin: 0;
padding: 0;
flex-wrap: wrap;
list-style: none;
}
li.item {
flex: 1 0 20%;
padding: 8px;
margin: 2px;
border-radius: 8px;
border: 1px solid rgba(61, 86, 233, 0.3);
text-align: center;
}
.col {
display: flex;
flex-direction: column;
align-items: center;
}
</style>
<!-- Header -->
<header class="intro-header">
<div class="container">
<div class="col-lg-5 mr-auto order-lg-2">
<h3><br>Tell me something about you... </h3>
</div>
</div>
</header>
<!-- Page Content -->
<section class="content-section-a">
<div class="container">
<dt>
<span>Pick the keywords you want to express when wearing perfume</span>
</dt>
<form action = "/getmatch" method="POST">
{% for keyword in keywords %}
<div class="elements">
<ul class="items ">
<li class="item col-xs-6 col-sm-3 col-md-3 col-lg-3">
<div data-toogle="buttons" class="col">
<span>{{ keyword.title }}</span>
</div>
</li>
</ul>
</div>
{% endfor %}
{% csrf_token %}
<button type="submit">Envoyer</button>
</form>
</div>
</section>
<!-- Bootstrap core JavaScript -->
<script src="static/vendor/jquery/jquery.min.js"></script>
<script src="static/vendor/popper/popper.min.js"></script>
<script src="static/vendor/bootstrap/js/bootstrap.min.js"></script>
{% endblock %}
I do not know if I should put it in a particular css file as style.css or if I should add it as <style> at the end or beginning of my file, I opted for this option that I found simpler.
Today I have buttones which looks good but still does not fit next to each other:
I don't know if it's related, but I don't get the multi-selection effect either.
In base.html I am loading the following style.css with the following line:
<link href="static/css/style.css" rel="stylesheet">
/*!
* Start Bootstrap - Landing Page (http://startbootstrap.com/template-overviews/landing-page)
* Copyright 2013-2017 Start Bootstrap
* Licensed under MIT (https://github.com/BlackrockDigital/startbootstrap-landing-page/blob/master/LICENSE)
*/
body, html {
width: 100%;
height: 100%;
}
body, h1, h2, h3, h4, h5, h6 {
font-family: 'Cormorant', serif;
}
.intro-header {
padding-top: 50px;
padding-bottom: 50px;
text-align: center;
color: #f8f8f8;
background: url(../img/intro-bg.jpg) no-repeat center center;
background-size: cover;
}
.intro-message {
position: relative;
padding-top: 20%;
padding-bottom: 20%;
}
.intro-message>h1 {
margin: 0;
text-shadow: 2px 2px 3px rgba(0, 0, 0, 0.6);
font-size: 5em;
}
.intro-divider {
width: 400px;
border-top: 1px solid #f8f8f8;
border-bottom: 1px solid rgba(0, 0, 0, 0.2);
}
.intro-message>h3 {
text-shadow: 2px 2px 3px rgba(0, 0, 0, 0.6);
}
.intro-social-buttons i {
font-size: 80%;
}
.recommendations {
padding-top: 10%;
}
#media(max-width:767px) {
.intro-message {
padding-bottom: 15%;
}
.intro-message>h1 {
font-size: 3em;
}
ul.intro-social-buttons>li {
display: block;
margin-bottom: 20px;
padding: 0;
}
ul.intro-social-buttons>li:last-child {
margin-bottom: 0;
}
.intro-divider {
width: 100%;
}
}
.network-name {
text-transform: uppercase;
font-size: 14px;
font-weight: 400;
letter-spacing: 2px;
}
.content-section-a {
padding: 50px 0;
background-color: #f8f8f8;
}
.content-section-b {
padding: 50px 0;
border-top: 1px solid #e7e7e7;
border-bottom: 1px solid #e7e7e7;
}
.section-heading {
margin-bottom: 30px;
}
.section-heading-spacer {
float: left;
width: 200px;
border-top: 3px solid #e7e7e7;
}
.banner {
padding: 100px 0;
color: #f8f8f8;
background: url(../img/banner-bg.jpg) no-repeat center center;
background-size: cover;
}
.banner h2 {
margin: 0;
text-shadow: 2px 2px 3px rgba(0, 0, 0, 0.6);
font-size: 3em;
}
.banner ul {
margin-bottom: 0;
}
.banner-social-buttons {
float: right;
margin-top: 0;
}
#media(max-width:1199px) {
ul.banner-social-buttons {
float: left;
margin-top: 15px;
}
}
#media(max-width:767px) {
.banner h2 {
margin: 0;
text-shadow: 2px 2px 3px rgba(0, 0, 0, 0.6);
font-size: 3em;
}
ul.banner-social-buttons>li {
display: block;
margin-bottom: 20px;
padding: 0;
}
ul.banner-social-buttons>li:last-child {
margin-bottom: 0;
}
}
.form {
padding-left: 50px;
padding: 50px;
}
.space {
padding-top: 60%;
}
footer {
padding: 50px 0;
background-color: #f8f8f8;
}
p.copyright {
margin: 15px 0 0;
}
Basically I would prefer to have them like this:
<!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="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<title>Documento de prueba</title>
<style>
.elements {
display: block;
}
ul.items {
display: flex;
margin: 0;
padding: 0;
flex-wrap: wrap;
list-style: none;
}
li.item {
display: flex;
flex-direction: column;
align-items: center;
flex: 1 0 20%;
padding: 8px;
margin: 2px;
border-radius: 8px;
border: 1px solid rgba(61, 86, 233, 0.3);
text-align: center;
}
</style>
</head>
<body>
<h1>Botones</h1>
<div class="elements">
<ul class="items">
<li class="item">
<i class="fa fa-home"></i>
<span>Label</span>
</li>
<li class="item">
<i class="fa fa-home"></i>
<span>Label</span>
</li>
<li class="item">
<i class="fa fa-home"></i>
<span>Label</span>
</li>
<li class="item">
<i class="fa fa-home"></i>
<span>Label</span>
</li>
<li class="item">
<i class="fa fa-home"></i>
<span>Label</span>
</li>
<li class="item">
<i class="fa fa-home"></i>
<span>Label</span>
</li>
<li class="item">
<i class="fa fa-home"></i>
<span>Label</span>
</li>
<li class="item">
<i class="fa fa-home"></i>
<span>Label</span>
</li>
</ul>
</div>
</body>
</html>

you can use a parent container whith a desired width and then inside it, set col-12 on every iteration.
<div class="row" style="width:30%">
{% for keyword in keywords %}
<div class="col-12">
<h3>{{ keyword.title }}</h3>
</div>
{% endfor %}
</div>
UPDATE
sorry, yesterday i was typen from my cellphone, look this approach maybe this help you to find a solution
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>stack</title>
<style>
.container{
width:900px;
min-height: 300px;
display:flex;
flex-direction:column;
grid-row-gap: 5px; /* Will be used instead by browsers that do not support `row-gap` */
row-gap: 5px; /* Used by browsers that support `row-gap` */
background-color:#ddd;
}
</style>
</head>
<body>
<div class="container">
<div>keyword</div>
<div>keyword</div>
<div>keyword</div>
<div>keyword</div>
<div>keyword</div>
<div>keyword</div>
<div>keyword</div>
<div>keyword</div>
<div>keyword</div>
<div>keyword</div>
</div>
</body>
</html>
it is very simple.
greetings

Related

changing position of sidebar

.page-wrapper {
grid-template-columns: 100%;
}
.middle-wrapper {
max-width: 960px;
margin-left: auto;
margin-right: auto;
padding: 25px;
border: 3px solid #ffffff;
}
.main-page-content {
margin-bottom: 0.5rem;
padding: 0;
}
.title1 {
font-family: tahoma;
font-size: 20px;
text-align: center;
margin-bottom: 2rem;
}
p {
margin: 1rem 0 2rem;
}
.callout {
background: rgba(238, 238, 238, 0.395);
border-radius: var(--elem-radius);
box-shadow: rgb(95, 95, 95);
display: flex;
flex-direction: column;
gap: 1rem;
margin: 2rem 0;
padding: 2rem;
text-align: left;
}
.boxed {
border: 1px solid rgb(78, 78, 78) ;
padding: 1rem;
width: 37em;
margin-left: auto;
margin-right: auto;
}
.textinrect {
word-spacing: 100px;
}
.sidebar {
grid-area: sidebar;
padding-top: 3rem;
max-width: 200px;
}
.list {
list-style: none;
padding-left: 0.5em;
}
.sidebar-heading {
color: Black;
font-size: 18px;
font-family: tahoma;
letter-spacing: 1.5px;
margin-left: 7px;
}
.subject-header {
color: rgba(0, 0, 0, 0.749);
font-size: 14px;
font-family: tahoma;
letter-spacing: 1px;
}
.subject {
margin-bottom: 1em;
}
.toggle {
margin-bottom: 15px;
}
.sub-topic {
color: black;
}
.toggle1 {
padding-top: 1em;
}
.toggle0 {
list-style: none;
padding-left: 1.5em ;
}
a {
text-decoration: none;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="fortest.css">
</head>
<body>
<div class="page-wrapper">
<div class="main-wrapper">
<div class="middle-wrapper">
<article class="main-page-content">
<h2 class="title1">How to create an HTML website</h2>
<div class="section1">
<p>1. Nav Bar</p>
<div class="callout">
<div class="boxed">
<div class="textinrect">
Yourwebsitename home about page3
</div>
</div>
</div>
</div>
</article>
</div>
<aside class="sidebar">
<nav class="sidebar-inner">
<p class="sidebar-heading">Subjects</p>
<div>
<ol class="list">
<li class="subject">
<a href="#">
<h5 class="subject-header">Subject1</h5>
</a>
</li>
<li class="toggle">
<details>
<summary>
All the school sunjects
</summary>
<ol class="toggle0">
<li class="toggle1">
<a class="sub-topic" href="#">The molecular mass and power</a>
</li>
<li class="toggle1">
<a class="sub-topic" href="#">the molecular mass and power</a>
</li>
</ol>
</details>
</li>
<li class="toggle">
<details>
<summary>
Not all school subjects
</summary>
</details>
</li>
</ol>
</div>
</nav>
</aside>
</div>
</body>
</html>
My goal is that the sidebar stays on the side at the very beginning of the document on the left side of the main text. For some reason it says down below the main section. I know this is a matter of position but I can not find the correct position. I would deeply appreciate any answer that you may give.
Try this,
#sidebar {
float: left;
width: 208px;
padding-top: 30px;
background-color:#D2D2D2;
margin-left:initial;
/*position: fixed;*/ //remove it
}
#content {
float: left; // change right to left
width: 564px;
padding-top: 30px;
}

Display Jinja loop side by side

(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

Everything stays together. Im trying to get the search bar and the logo next to each other on the left side and extend the search to the end

Im trying to get the logo and search bar close together on the left side and extend the search bar to the right more. I dont know what else to do. Also I need to make a join and log in button to the right of everything. I also cant seem to get the submit button on the right side of the search field. Basically needs to look like this
#import url('https://fonts.googleapis.com/css?family=Poppins');
body {
font-family: 'Poppins';
}
header>div {
padding: 0 25px;
display: flex;
justify-content: space-between;
align-items: center;
border-bottom: 1px solid lightgray;
}
nav {
width: 600px;
}
nav ul {
list-style: none;
display: flex;
justify-content: space-between;
align-items: center;
}
nav a {
text-decoration: none;
color: black;
}
.blackHeart {
width: 20px;
margin-right: 1rem;
}
.searchmenu {
padding-top: 12.5px;
padding-bottom: 12.5px;
display: flex;
justify-content: space-between;
align-items: center;
}
.logo {
width: 50px;
margin-left: .3rem;
display: right;
}
.topnav .search-container {
float: right;
}
.topnav input[type=text] {
padding: 6px;
font-size: 17px;
border: none;
}
.topnav .search-container button {
float: right;
padding: 6px;
background: red;
font-size: 17px;
border: none;
cursor: pointer;
color: white;
}
.topnav .search-container button:hover {
background: black;
}
.search {
background-color: rgba(211, 211, 211, 0.463);
float: right;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="./style.css">
<title>Document</title>
</head>
<header>
<div>
<div>
<img class="blackHeart" src="images/black-heart.png" alt="black heart" />
<span> Nifty Penguin Magic </span>
</div>
<nav>
<ul>
<li> npm Enterprise </li>
<li> Products </li>
<li> Solutions </li>
<li> Resources </li>
<li> Docs </li>
<li> Support </li>
</ul>
</nav>
</div>
<div class="searchmenu">
<ul>
<div>
<img class="logo" src="images/npm-logo.png" alt="npm logo">
</div>
<div class="topnav">
<div class="search-container">
<form>
<input type="text" placeholder="Search.." name="search" class="search">
<button type="submit">Submit</button>
</form>
</div>
</div>
<div>
Join Log In
</div>
</ul>
</div>
</header>
<body>
</body>
</html>
Is this work? I cancelled all float: right from your code and replaced with flexbox
#import url('https://fonts.googleapis.com/css?family=Poppins');
body {
font-family: 'Poppins';
}
header>div {
padding: 0 25px;
display: flex;
justify-content: space-between;
align-items: center;
border-bottom: 1px solid lightgray;
}
nav {
width: 600px;
}
form {
display: flex;
}
nav ul {
list-style: none;
display: flex;
justify-content: space-between;
align-items: center;
}
nav a {
text-decoration: none;
color: black;
}
.blackHeart {
width: 20px;
margin-right: 1rem;
}
.searchmenu {
padding-top: 12.5px;
padding-bottom: 12.5px;
display: flex;
justify-content: space-between;
align-items: center;
}
.logo {
width: 50px;
margin-left: .3rem;
display: right;
}
.topnav, .searchContainer {
width: 100%;
}
.topnav input[type=text] {
padding: 6px;
font-size: 17px;
border: none;
}
.topnav .search-container button {
width: 18%;
padding: 6px;
background: red;
font-size: 17px;
border: none;
cursor: pointer;
color: white;
}
.topnav .search-container button:hover {
background: black;
}
.search {
background-color: rgba(211, 211, 211, 0.463);
width: 100%;
border: none;
outline: none;
}
.searchmenu ul {
padding: 0;
width: 100%;
display: flex;
align-items: center;
}
.searchDiv {
width: 78%;
display: flex;
align-items: center;
border: 1px solid black;
background-color: rgba(211, 211, 211, 0.463);
}
.icon {
width: 20px;
height: 20px;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="./style.css">
<title>Document</title>
</head>
<header>
<div>
<div>
<img class="blackHeart" src="images/black-heart.png" alt="black heart" />
<span> Nifty Penguin Magic </span>
</div>
<nav>
<ul>
<li> npm Enterprise </li>
<li> Products </li>
<li> Solutions </li>
<li> Resources </li>
<li> Docs </li>
<li> Support </li>
</ul>
</nav>
</div>
<div class="searchmenu">
<ul>
<div>
<img class="logo" src="images/npm-logo.png" alt="npm logo">
</div>
<div class="topnav">
<div class="search-container">
<form>
<div class="searchDiv">
<svg class="icon" version="1.1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" xmlns:xlink="http://www.w3.org/1999/xlink" enable-background="new 0 0 512 512">
<g>
<path d="m495,466.1l-119.2-119.2c29.1-35.5 46.5-80.8 46.5-130.3 0-113.5-92.1-205.6-205.6-205.6-113.6,0-205.7,92.1-205.7,205.7s92.1,205.7 205.7,205.7c49.4,0 94.8-17.4 130.3-46.5l119.1,119.1c8,8 20.9,8 28.9,0 8-8 8-20.9 0-28.9zm-443.2-249.4c-1.42109e-14-91 73.8-164.8 164.8-164.8 91,0 164.8,73.8 164.8,164.8s-73.8,164.8-164.8,164.8c-91,0-164.8-73.8-164.8-164.8z"/>
</g>
</svg>
<input type="text" placeholder="Search.." name="search" class="search">
</div>
<button type="submit">Submit</button>
</form>
</div>
</div>
<div>
Join Log In
</div>
</ul>
</div>
</header>
<body>
</body>
</html>
The problem is you are going with floats also i have made sime changes to your overall html and css you can compare with your code.
#import url("https://fonts.googleapis.com/css?family=Poppins");
* {
padding: 0;
margin: 0;
box-sizing: border-box;
}
body {
font-family: "Poppins";
}
header > .firstnav {
padding: 12.5px 25px;
display: flex;
justify-content: space-between;
align-items: center;
border-bottom: 1px solid lightgray;
}
nav {
width: 600px;
}
nav ul {
list-style: none;
display: flex;
justify-content: space-between;
align-items: center;
}
nav a {
text-decoration: none;
color: black;
}
.blackHeart {
width: 20px;
margin-right: 1rem;
}
.searchmenu {
padding: 12.5px 25px;
display: flex;
align-items: center;
justify-content: space-between;
}
.logo {
width: 50px;
margin-left: 0.3rem;
}
.searchmenu form {
position: relative;
}
.searchmenu form svg {
width: 33px;
background: beige;
padding: 7px;
position: absolute;
color: black;
height: 34px;
top: -1px;
left: 29px;
}
.searchmenu input[type="text"] {
padding: 6px 35px;
font-size: 17px;
border: none;
background-color: rgba(211, 211, 211, 0.463);
margin-left: 30px;
width: 1050px;
}
.searchmenu button {
padding: 6px;
background: red;
font-size: 17px;
border: none;
cursor: pointer;
color: white;
}
.searchmenu ul li {
list-style: none;
padding: 5px 0;
}
.searchmenu ul li a {
text-decoration: none;
padding: 0 15px;
}
.searchmenu ul {
display: flex;
}
.join {
border: 1px solid grey;
}
and your HTML
<header>
<div class="firstnav">
<div>
<img
class="blackHeart"
src="images/black-heart.png"
alt="black heart"
/>
<span> Nifty Penguin Magic </span>
</div>
<nav>
<ul>
<li> npm Enterprise </li>
<li> Products </li>
<li> Solutions </li>
<li> Resources </li>
<li> Docs </li>
<li> Support </li>
</ul>
</nav>
</div>
<div class="searchmenu">
<div>
<img class="logo" src="images/npm-logo.png" alt="npm logo" />
</div>
<!-- <div class="topnav"> -->
<!-- <div class="search-container"> -->
<form>
<svg
class="icon"
version="1.1"
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 512 512"
xmlns:xlink="http://www.w3.org/1999/xlink"
enable-background="new 0 0 512 512"
>
<g>
<path
d="m495,466.1l-119.2-119.2c29.1-35.5 46.5-80.8 46.5-130.3 0-113.5-92.1-205.6-205.6-205.6-113.6,0-205.7,92.1-205.7,205.7s92.1,205.7 205.7,205.7c49.4,0 94.8-17.4 130.3-46.5l119.1,119.1c8,8 20.9,8 28.9,0 8-8 8-20.9 0-28.9zm-443.2-249.4c-1.42109e-14-91 73.8-164.8 164.8-164.8 91,0 164.8,73.8 164.8,164.8s-73.8,164.8-164.8,164.8c-91,0-164.8-73.8-164.8-164.8z"
/>
</g>
</svg>
<input
type="text"
placeholder="Search.."
name="search"
class="search"
/>
<button type="submit">Submit</button>
</form>
<!-- </div> -->
<!-- </div> -->
<ul>
<li class="join">Join</li>
<li>Login</li>
</ul>
</div>
</header>

Background-color isn't responsive

I'm a newbie at this. I have a problem. I'm creating a personal page where I want a background-color in the top part of the page (covering a section) and I want another background-color in the middle of the page (covering another section).
The thing is that I did that but when I go to developer tools the design it doesn't responsive. My body background kinda "creates" a margin aside my second background.
I don't know if I'm explain it well but here is my code and the bug that I have:
* {
font-family: 'Fredoka', sans-serif;
margin: 0%;
padding: 0%;
}
body {
background-color: #3a5056;
color: white;
text-align: center;
}
html,
body {
height: 100%;
}
.middle {
background-color: white;
height: 1866px;
padding: 50px;
margin-top: 230px;
}
.cards-list {
z-index: 0;
width: 100%;
display: flex;
justify-content: space-around;
flex-wrap: wrap;
}
.card {
margin: 30px auto;
width: 300px;
height: 300px;
border-radius: 40px;
box-shadow: 5px 5px 30px 7px rgba(0, 0, 0, 0.25), -5px -5px 30px 7px rgba(0, 0, 0, 0.22);
cursor: pointer;
transition: 0.4s;
}
.card .card_image {
width: inherit;
height: inherit;
border-radius: 40px;
}
.card .card_image img {
width: inherit;
height: inherit;
border-radius: 40px;
object-fit: cover;
}
.card .card_title {
text-align: center;
border-radius: 0px 0px 40px 40px;
font-family: sans-serif;
font-weight: bold;
font-size: 30px;
margin-top: -80px;
height: 40px;
color: #2c3d42;
}
section .intro {
height: 40px;
width: 850px;
padding: 6%;
}
.intro {
display: flex;
justify-content: center;
align-items: center;
align-self: center;
min-width: 850px;
}
.intro:nth-child() {
align-self: center;
}
.abt-me {
position: relative;
width: 800px;
height: 250px;
padding: 1%;
color: #2c3d42;
display: block;
content: "";
margin-top: -2550px;
border: 1px hidden;
font-size: 18px;
border-radius: 40px;
box-shadow: 5px 5px 30px 7px rgba(0, 0, 0, 0.25);
-webkit-box-shadow: 2px 3px 17px 6px rgba(0, 0, 0, 0.3);
-moz-box-shadow: 2px 3px 17px 6px rgba(0, 0, 0, 0.3);
}
.text-box {
padding: 1%;
margin-top: -8px;
font-size: 21px;
width: 750px;
height: 250px;
margin-left: 2%;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link rel="stylesheet" href="styles.css">
<link href="https://fonts.googleapis.com/css2?family=Fredoka:wght#300;400&display=swap" rel="stylesheet">
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/font-awesome/latest/css/font-awesome.min.css">
<title></title>
</head>
<body>
<section class="main">
<div id="name">
<h1>Hello, I'm <span id="me">Sapph</span></h1>
</div>
<div id="scroll">
<section id="section02" class="demo">
<span></span>
</section>
</div>
<nav class="social">
<ul>
<li>Twitter <i class="fa fa-twitter"></i></li>
<li>Github <i class="fa fa-github"></i></li>
<li>Linkedin <i class="fa fa-linkedin"></i></li>
</ul>
</nav>
</section>
<section class="middle">
<div id="cards">
<div class="cards-list">
<div class="card 1">
<div class="card_image"></div>
<div class="card_title title-white">
<p>Contact</p>
</div>
</div>
<div class="card 3">
<div class="card_image">
</div>
<div class="card_title">
<p>Projects</p>
</div>
</div>
</div>
</div>
</div>
</section>
<section class="intro">
<div class="abt-me">
<h2 style="margin-bottom: 12px" ;><b>
About Me</b>
</h2>
<div class="text-box">
<p>
<center>Hello, I'm...</center>
</p>
</div>
</div>
</section>
<footer>&copy Copyright</footer>
</body>
</html>
This is my problem: https://prnt.sc/w4Zkw0QU7P67
This is what I need: https://prnt.sc/UhNmn4djohPS
I took the photos in the developer tools. Thanks
Try to find the #media section for max-width:890px in your style.css and edit the "section" tag style. or past the below code on your page, this should help. It is the amount of padding added on the section for screen width less than 890px.
#media only screen and (max-width: 890px) {
section{
margin: 0px;
padding: 10px;
}
}
If you want to change the section style for all screen widths just use:
#media only screen and (min-width: 360px) and (max-width: 1360px) {
section{
margin: 0px;
padding: 10px;
}
}

Image not centering in bootstrap

Having tried the solutions suggested in the other posts, I'm left to post my novice code in which the embedded image simply will not centre and I haven't a clue why. The image should appear in the middle of a login screen/box; it did for the guy who did the demo, yet I've had to alter his CSS to make it marginally better. Still, the image will not centre. Does anyone have any insight?
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Standard Meta Tags -->
<!-- Bootstrap & Related Links-->
<link rel="stylesheet" href="static/styles.css">
<title>Project</title>
</head>
<body>
<!-- cont is the entire box; changing its CSS changes its position on the page -->
<div class="cont">
<!-- box is the area that contains the image, username, and pass fields, but not the button bar and login buttons -->
<div class="box">
<!-- Creates the entire top row with close button and three circular buttons
<div class="row top">
<div class="left">
<i class="fa fa-times close"></i>
</div>
<div class="right">
<i class=" fa fa-circle but one"></i>
<i class=" fa fa-circle but two"></i>
<i class=" fa fa-circle but three"></i>
</div>
</div>
-->
<div class="row middle sg">
<div class="row pic sg">
<div class="col-md-4 col-md-offset-4">
<img src="static/fleur.jpeg" alt="fleur-de-lis" class="photo">
</div>
</div>
<form action="#" class="form-horizontal form">
<div class="input-group y">
<span class="input-group-addon"><i class="fa fa-user use"></i></span>
<input type="text" class="form-control" placeholder="Username">
</div>
<div class="input-group">
<span class="input-group-addon"><i class="fa faunlock-alt use"></i></span>
<input type="password" class="form-control" placeholder="Password">
</div>
</form>
</div>
<div class="row base sg">
<h2 class="text-center login">Login</h2>
</div>
</div>
</div>
</body>
</html>
CSS
html, body {
width: 100%;
height: 100%;
}
.cont {
width: 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
}
.box {
background-color: #2B2B35;
width: 400px;
border-radius: 10px;
}
.top {
width: 100%;
background-color: #24242E;
margin: 0;
border-radius: 10px 10px 0 0;
padding: 0 15px;
}
.left {
float: left;
}
.right {
float: right;
}
.close {
padding: 18px 0;
font-size: 20px;
color: #fff;
}
.but {
padding: 18px 0 18px 5px;
font-size: 20px;
}
.but:hover {
cursor: pointer;
}
.one {
color: #F4CB61;
}
.two {
color: #DB5594;
}
.three {
color: #6451E8;
}
.photo {
width: 200px;
border-radius: 50%;
}
.sg {
display: block;
margin-left: auto;
margin-right: auto;
align-items: center;
justify-content: center;
}
.pic {
margin: 40px 0 30px 0;
}
.form {
padding: 0 40px 40px 40px;
}
.login {
padding: 12px 0;
margin: 0;
}
.base {
background-color: #3FA752;
border-radius: 0 0 10px 10px;
color: #fff;
}
.base:hover {
cursor: pointer;
}
.base h2{
font-weight: 600;
font-size: 26px;
}
.user {
color: #ccc;
}
.y {
padding-bottom: 15px;
}
input[type=text],
input[type=password] {
background: 0, 0;
border: 0;
box-shadow: none;
border-radius: 0;
border-bottom: 1px solid #9446B6;
}
.input-group-addon {
background: 0 0;
border: 0;
border-radius: 0;
border-bottom: 1px solid #9AA6B6;
}
.use {
color: #9AA6B6;
}
input[type=text],
input[type=password]:focus{
box-shadow: none !important;
color: #FF3F3F;
}
Updated:
Removing these classes class="col-md-4 col-md-offset-4" and adding a class to center the image fixes the problem.
html, body {
width: 100%;
height: 100%;
}
.cont {
width: 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
}
.box {
background-color: #2B2B35;
width: 400px;
border-radius: 10px;
}
.top {
width: 100%;
background-color: #24242E;
margin: 0;
border-radius: 10px 10px 0 0;
padding: 0 15px;
}
.left {
float: left;
}
.right {
float: right;
}
.close {
padding: 18px 0;
font-size: 20px;
color: #fff;
}
.but {
padding: 18px 0 18px 5px;
font-size: 20px;
}
.but:hover {
cursor: pointer;
}
.one {
color: #F4CB61;
}
.two {
color: #DB5594;
}
.three {
color: #6451E8;
}
.text-center {
text-align: center;
}
.photo {
width: 200px;
border-radius: 50%;
}
.sg {
display: block;
margin-left: auto;
margin-right: auto;
align-items: center;
justify-content: center;
}
.pic {
margin: 40px 0 30px 0;
}
.form {
padding: 0 40px 40px 40px;
}
.login {
padding: 12px 0;
margin: 0;
}
.base {
background-color: #3FA752;
border-radius: 0 0 10px 10px;
color: #fff;
}
.base:hover {
cursor: pointer;
}
.base h2{
font-weight: 600;
font-size: 26px;
}
.user {
color: #ccc;
}
.y {
padding-bottom: 15px;
}
input[type=text],
input[type=password] {
background: 0, 0;
border: 0;
box-shadow: none;
border-radius: 0;
border-bottom: 1px solid #9446B6;
}
.input-group-addon {
background: 0 0;
border: 0;
border-radius: 0;
border-bottom: 1px solid #9AA6B6;
}
.use {
color: #9AA6B6;
}
input[type=text],
input[type=password]:focus{
box-shadow: none !important;
color: #FF3F3F;
}
<html lang="en">
<head>
<!-- Standard Meta Tags -->
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<!-- Bootstrap & Related Links-->
<link rel="stylesheet" href="static/styles.css">
<title>Project</title>
</head>
<body>
<!-- cont is the entire box; changing its CSS changes its position on the page -->
<div class="cont">
<!-- box is the area that contains the image, username, and pass fields, but not the button bar and login buttons -->
<div class="box">
<!-- Creates the entire top row with close button and three circular buttons
<div class="row top">
<div class="left">
<i class="fa fa-times close"></i>
</div>
<div class="right">
<i class=" fa fa-circle but one"></i>
<i class=" fa fa-circle but two"></i>
<i class=" fa fa-circle but three"></i>
</div>
</div>
-->
<div class="row middle sg">
<div class="row pic sg">
<div class="text-center">
<img src="https://placeimg.com/200/200/nature" alt="fleur-de-lis" class="photo">
</div>
</div>
<form action="#" class="form-horizontal form">
<div class="input-group y">
<span class="input-group-addon"><i class="fa fa-user use"></i></span>
<input type="text" class="form-control" placeholder="Username">
</div>
<div class="input-group">
<span class="input-group-addon"><i class="fa faunlock-alt use"></i></span>
<input type="password" class="form-control" placeholder="Password">
</div>
</form>
</div>
<div class="row base sg">
<h2 class="text-center login">Login</h2>
</div>
</div>
</div>
</body>
</html>
By default images are inline-block elements, they follow the regular flow and should be centered with text-align (set in the parent).
Images can be set to display as block elements, to center these the value of width must be set (amount, percent,...), and both left and right margins set to auto.
.container {
width: 100%;
}
.tex-center {
text-align: center;
}
#inline-example {
display: inline-block; /* Default value*/
}
#block-example {
display: block;
max-width: 200px;
margin: 0 auto 0 auto;
}
<h3>Inline centered image</h3>
<div class="container tex-center"><img id="inline-example" src="https://placeimg.com/200/200/nature"></div>
<h3>Block centered image</h3>
<div class="container"><img id="block-example" src="https://placeimg.com/200/200/people"></div>
How to find out similar CSS issues. Using Chrome's devtools (or similar) we can see there's a margin in the left pushing the image. col-md-4 col-md-offset-4 are both Bootsrap classes used for a grid setup, trying and removing them gives us the solution.
Try this:
.photo {
width: 200px;
border-radius: 50%;
display: block;
margin: auto;
}
To center an image in a div, you should normally set the display to block and margin to auto on the img.
If you are talking about this image <img src="static/fleur.jpeg" alt="fleur-de-lis" class="photo"> then you should add to your 'photo' class:
display:block;
margin: 0 auto;
Make sure other CSS wont prevent those lines to work and your image should centre itself within your col-element.
Your image is in column with offset, remove column classes (event whole div) and all will work well with:
.photo {
display: block; // defining element as block
margin: 0 auto; // and auto side margin
width: 200px;
border-radius: 50%;
}
Example:
https://codepen.io/themeler/pen/QqNpWv