Ive been working on this form but I am now having trouble getting things to line up properly. On smaller sizes its not to big an issue, but on large screens the problem is very noticeable.
Two main issues I am finding is that I have some social links that is getting extra spacing from somewhere, though there is no padding or margins between them that I can see. Also the actual form itself is not filling in the whole space. Im not exactly sure how to fix the spacing issues here.
Anyone offer any tips?
Here is a JsFiddle of the code the code saved to SO and Jsfiddle are exact same, though it appears they are giving different results. Not sure why, though clearly I probably messed something up here.
https://jsfiddle.net/Tsukiyono/aq9Laaew/283640/
Here is another link showing things on my gitpages link:
https://tsukiyonocm.github.io/test/
edit A image of the layout I am trying to achieve.
https://imgur.com/a/al8KEMh
body {
background-color: black;
}
/** Contact
---------------------------------------------------------*/
#contactus {
color: black;
max-height: 62.5rem;
width: auto;
}
.contact-title {
font-family: futura-pt-condensed, sans-serif;
font-weight: 700;
padding: 1rem 0;
}
.contact-info {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
text-align: center;
}
.custom-contact {
max-height: 15rem;
}
.social {
font-weight: 700;
}
.custom-social {
max-height: 15rem;
width: auto;
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
}
.social-contact ul {
list-style: none;
display: flex;
justify-content: center;
padding: 0;
}
.social-contact ul li {
padding: 0 1rem;
}
.btn-sub {
letter-spacing: 1.5;
color: black;
background-color: #fff;
font-weight: 700;
border-radius: 0.15rem;
white-space: normal;
}
.btn-form {
width: 100%;
letter-spacing: 1.5;
color: black;
background-color: #fff;
font-weight: 700;
border-radius: 0.15rem;
}
form {
max-width: 100%;
margin: 0 .5rem;
}
.form-control {
background-color: rgb(46, 46, 46);
border: 1px solid white;
border-radius: 0.2rem;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet" />
<section id="contactus">
<div class="container">
<div class="row">
<div class="col-12 text-center">
<h1 class="display-3 contact-title">Contact Us</h1>
</div>
</div>
<div class="row">
<div class="col-12 col-lg-6">
<div class="row contact-info d-flex flex-md-row flex-lg-column">
<div class="col-12 col-md-6 custom-contact">
<h3>- Our Office -</h3>
<address>
SOCKEROO Marketing<br>
123 Address Rd.<br>
Pittsburgh, PA<br>
15222<br>
TEL - 555.555.5555<br>
Email - sockeroomarketing#gmail.com
</address>
</div>
<div class="col-12 col-md-6 custom-social">
<p class="social">- Say Hello -</p>
<div class="social-contact">
<ul class="">
<li><i class="fab fa-inverse fa-twitter-square fa-lg"></i></li>
<li><i class="fab fa-inverse fa-facebook-square fa-lg"></i></li>
<li><i class="fab fa-inverse fa-linkedin fa-lg"></i></li>
<li><i class="fab fa-inverse fa-instagram fa-lg"></i></li>
</ul>
</div>
<button class="btn btn-sub">Subscribe to Our Newsletter</button>
</div>
</div>
</div>
<div class="col-12 col-lg-6 m-0 p-0">
<form action="">
<div class="form-group">
<input type="text" class="form-control" placeholder="Name">
</div>
<div class="form-group">
<input type="text" class="form-control" placeholder="Company or Organization">
</div>
<div class="form-group">
<input type="email" class="form-control" placeholder="Email Address">
</div>
<div class="form-group">
<input type="tel" class="form-control" placeholder="Phone Number">
</div>
<div class="form-group">
<textarea name="comment" class="form-control" placeholder="Tell us a bit about your project, timeline, and budget"></textarea>
</div>
<button class="btn btn-form">Submit</button>
</form>
</div>
</div>
</div>
</section>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
In regards to the inconsistency between JSFiddle and Github pages, I believe the problem lies in the way bootstrap implements their col-md-6 class. Namely, the flex-basis property.
For reference, this is what I see their class to be, based on the element inspector in chrome:
#media (min-width: 768px)
.col-md-6 {
-ms-flex: 0 0 50%;
flex: 0 0 50%;
max-width: 50%;
}
(A little context: flex is shorthand for defining flex-grow, flex-shrink, and flex-basis, in that order. You can find that info in this article on CSS-Tricks: here and a little more detail on flex basis just above it, here).
As you can see, they're setting flex basis to 50%. Once I set both the jsfiddle and gitpages' flex property to flex: 0 0 auto, the spacing was consistent on both of those pages, leading me to wonder if flex-basis is calculating 50% to be one value in the JSFiddle and another value in your Github pages. As for a solution, what you can do is create a custom class, let's say .cust-col-md-6, and copy the ruleset defined by bootstrap, but change the flex-basis of the property to auto:
#media (min-width: 768px)
.cust-col-md-6 {
-ms-flex: 0 0 auto;
flex: 0 0 auto;
max-width: 50%;
}
Then from here you can set that as your class instead of using .col-md-6:
<div class="col-12 cust-col-md-6 custom-social">
Related
I can't get this css grid to do these 2 things..
Value column should always show the entire string, not wrap, and not overflow
The hearts column should always stay lined up vertically
Here's an explanation of the problem in an image:
I've been working on this for too long, thank you for helping me!!! <3
Codepen simplified down: https://codepen.io/naaadz/pen/OJQZvgB
This is what I have to start with:
grid-template-columns: auto 150px auto 1fr;
I am not sure that it is possible with your current HTML structure.
If you change the grid element to hold your columns, you can achieve it.
Currently, you are having a lot of grids with a single row.
Below is an example of what I mean.
You can change the first column width to auto.
I saw that you are limiting it to 150px, so I used the minmax() property.
.box {
width: 300px;
background: lightgray;
overflow: hidden;
display: grid;
grid-template-columns: minmax(40px, 150px) 1fr;
gap: 10px;
padding: 3px 5px;
align-items: center;
}
.item {
display: flex;
align-items: center;
}
.font-icon {
margin-right: 10px;
}
.value {
text-align: right;
white-space: nowrap;
}
.truncate {
display: -webkit-box !important;
-webkit-box-orient: vertical;
-webkit-line-clamp: 1;
overflow: hidden;
word-break: break-all;
}
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<div class="box">
<div class="item">
<i class="font-icon material-icons">circle</i>
<span class="name truncate">Some value here</span>
</div>
<div class="item">
<i class="font-icon material-icons">favorite</i>
<span class="value item-right">16,000 UNITS</span>
</div>
<div class="item">
<i class="font-icon material-icons">circle</i>
<span class="name truncate">Some longer value here longer</span>
</div>
<div class="item">
<i class="font-icon material-icons">favorite</i>
<span class="value item-right">33,000 PPL</span>
</div>
<div class="item">
<i class="font-icon material-icons">circle</i>
<span class="name truncate">Some other value</span>
</div>
<div class="item">
<i class="font-icon material-icons">favorite</i>
<span class="value item-right">23,000,000 PPL</span>
</div>
</div>
I need to display a list of scheduled jobs in an endless scroll list of angular material,
for each element in the list, I need to divide it into 3 columns using flexbox.
in each column, I want to display certain data.
for some reason, I'm not able to add space between columns inside the list.
here is my code in html
<app-nav>
<div class="grid-container">
<div class="row1">
<mat-grid-list cols="6" rowHeight="100px">
<mat-grid-tile [colspan]="1" [rowspan]="1" [style.background]="lightgreen">
<h2>All Scheduled Jobs</h2>
</mat-grid-tile>
<mat-grid-tile [colspan]="4" [rowspan]="1" [style.background]="lightgreen">
</mat-grid-tile>
<mat-grid-tile [colspan]="1" [rowspan]="1" [style.background]="lightgreen">
<button (click)="openCreateScheduledJobDialog()" mat-mini-fab color="primary"
aria-label="Example icon button with a plus one icon">
<mat-icon>plus_one</mat-icon>
</button>
</mat-grid-tile>
</mat-grid-list>
</div>
<div class="row2"> // the problem is in this part:
<cdk-virtual-scroll-viewport itemSize="70" class="example-viewport">
<mat-list>
<mat-list-item *cdkVirtualFor="let scheduledjob of scheduledJobs" class="example-item">
<div class="flex-container-list-item"> // here is the flex that i need to fix
<div class="details">
<h3 matLine>{{getJob(scheduledjob.jobID)}} Job</h3>
<h4 matLine> Status: {{getJobStatus(scheduledjob.isActive)}}</h4>
<p matLine>
<span> Start time: {{scheduledjob.startTime | date}} </span>
</p>
<p matLine>
<span> End time: {{scheduledjob.endTime | date}}</span>
</p>
<p matLine>
<span> Runs Every: {{scheduledjob.daysFrequency}} days
</span>
</p>
<p matLine>
<button mat-stroked-button color="primary"
(click)="openMachineDetailsDialog(scheduledjob.machineSerialNumber)">Machine Details</button>
</p>
</div>
<div class="edit"> <button mat-flat-button color="primary" (click)="openUpdateScheduledJobDialog(scheduledjob)">Edit</button></div>
<div class="delete"> <button mat-raised-button (click)="delete(scheduledjob)" color="warn">Delete</button>
</div>
</div>
<mat-divider></mat-divider>
</mat-list-item>
</mat-list>
</cdk-virtual-scroll-viewport>
</div>
<div class="row3">
</div>
</div>
</app-nav>
note that im using angular material cdk-virtual-scroll-viewport
here is the css:
.row1 {
grid-area: row1;
}
.row2 {
grid-area: row2;
}
.row3 {
grid-area: row3;
}
.grid-container {
display: grid;
grid-template-areas:
'row1 row1 row1'
'row2 row2 row2'
'row3 row3 row3 '
;
grid-gap: 2px;
padding: 2px;
}
.grid-container>div {
text-align: center;
padding: 10px 0;
font-size: 15px;
}
.example-viewport {
height: 600px;
border: 2px solid gray;
}
.example-item {
height: 50px;
}
/* ******************* list item flex ***************** */
.details {
background-color:lightcoral ;
}
.edit {
background-color: lightgreen;
}
.delete {
background-color: lightskyblue;
}
.flex-container-list-item {
display: flex;
border: 6px solid red;
justify-content: space-between;
--gap: 10rem;
flex-wrap: wrap;
}
.grid-container-list-item>div {
text-align: center;
padding: 10px 0;
font-size: 15px;
}
Use either the gap property on the flex container, or set [margin](http://developer.mozilla.org/en-US/docs/Web/CSS/margin) on your flex items.
Your current solution doesn’t seem to be working because you set a CSS custom property --gap: 10rem on your flex container, but then don’t actually apply that property (at least in the provided code).
You can use gap, and that will ensure a fixed amount between the flex items. Browser support for gap is good, with the exception of Safari before version 14.1.
Alternatively, you could set margin-right on all your flex items with the exception of the last item to achieve a similar effect.
Here’s a working (simplified) example:
.flex-container-list-item {
display: flex;
border: 6px solid red;
gap: 2rem;
flex-wrap: wrap;
}
.details {
background-color: lightcoral;
}
.edit {
background-color: lightgreen;
}
.delete {
background-color: lightskyblue;
}
<div class="flex-container-list-item">
<div class="details">
<h3>Job</h3>
<h4>Status: active</h4>
<p>
<span> Start time: 2 PM</span>
</p>
<p>
<span> End time: 4 PM</span>
</p>
<p>
<span> Runs Every: 3 days </span>
</p>
<p>
<button>Machine Details</button>
</p>
</div>
<div class="edit">
<button
mat-flat-button
color="primary"
(click)="openUpdateScheduledJobDialog(scheduledjob)"
>
Edit
</button>
</div>
<div class="delete">
<button mat-raised-button (click)="delete(scheduledjob)" color="warn">
Delete
</button>
</div>
</div>
Ideally you should do the followings and it should work :
.container{
display : flex;
flex-flow: row wrap;
justify-content: space-between;
}
.item{
margin: 10px;
height: 100px;
width: 100px;
}
.item1{
background-color: red;
}
.item2{
background-color: yellow;
}
<div class="container">
<div class="item item1"></div>
<div class="item item2"></div>
</div>
even though your question is not so clear. you can do following update on your HTML and css files :
.flex-container-list-item{
display: flex;
flex-flow: row wrap;
justify-content: space-between;
}
<div class="flex-container-list-item">
<div class="details">details contents</div>
<div class="action">
<button
mat-flat-button
color="primary"
(click)="openUpdateScheduledJobDialog(scheduledjob)"
>
Edit
</button>
<button mat-raised-button (click)="delete(scheduledjob)" color="warn">
Delete
</button>
</div>
</div>
I'm a CSS/HTML newbie and have tried to do research on this but am stumped. I've seen others with a similar problem, but their submit button and text field are only slightly misaligned. Mine is vertical but I want it horizontal.
I tried adding display: inline-block to both the text field and submit button elements, but it didn't fix the issue.
Here is the embed code for the form:
<!-- Begin MailChimp Signup Form -->
<div id="mc_embed_signup">
<form action="https://julienkozak.us14.list-manage.com/subscribe/post?
u=f46b7a895f8d332e0127067ad&id=4fbc88f22f" method="post" id="mc-
embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate"
target="_blank" novalidate>
<div id="mc_embed_signup_scroll">
<div class="mc-field-group">
<input type="email" value="" name="EMAIL" class="required email" id="mce-
EMAIL" placeholder="e-mail address">
</div>
<div id="mce-responses" class="clear">
<div class="response" id="mce-error-response" style="display:none">
</div>
<div class="response" id="mce-success-response" style="display:none">
</div>
</div> <!-- real people should not fill this in and expect good things -
do not remove this or risk form bot signups-->
<div style="position: absolute; left: -5000px;" aria-hidden="true"><input
type="text" name="b_f46b7a895f8d332e0127067ad_4fbc88f22f" tabindex="-1"
value=""></div>
<div class="clear" ><input type="submit" value="Get Updates"
name="subscribe" id="mc-embedded-subscribe" class="button"></div>
</div>
</form>
</div>
<!--End mc_embed_signup-->
The rest of the code you see is the CSS :
/* MAILCHIMP top form */
#mc_embed_signup {
text-align: center;
width: 300px;
}
/* Styles the header text above the inputs */
#mc_embed_signup h2 {
font-size: 18px;
margin: 0 0 20px;
color: #000000;
text-align: center;
}
/* Adds extra space around the input boxes */
#mc_embed_signup .mc-field-group {
padding: 10px 0;
}
/* Styles the input boxes */
#mc_embed_signup input {
width: 200px;
background: white;
height: 40px;
border-radius: 0px;
display: inline-block;
}
/* Styles the subscribe button */
#mc_embed_signup .button {
background-color: gray;
color: #ffffff;
margin: 0 auto;
width: 100px;
height: 40px;
display: inline-block;
}
julienkozak.com/ The form is at the top of this page.
Thank you so much for your patience with me.
Have you considered using bootstrap?
You could also use bootstrap's row functionality to dynamically set the fields of your div tag to a certain part of the page. This has the added benefit of making your page responsive to a variety of screens and monitors.
You can use flexbox on the wrapping div mc_embed_signup_scroll using display:flex. I put margin-top:10px on the button to align it with the input field.
/* MAILCHIMP top form */
#mc_embed_signup {
text-align: center;
width: 300px;
}
/* Styles the header text above the inputs */
#mc_embed_signup h2 {
font-size: 18px;
margin: 0 0 20px;
color: #000000;
text-align: center;
}
/* Adds extra space around the input boxes */
#mc_embed_signup .mc-field-group {
padding: 10px 0;
}
/* Styles the input boxes */
#mc_embed_signup input {
width: 200px;
background: white;
height: 40px;
border-radius: 0px;
}
/* Styles the subscribe button */
#mc_embed_signup .button {
background-color: gray;
color: #ffffff;
margin: 0 auto;
width: 100px;
height: 40px;
margin-top:10px;
}
#mc_embed_signup_scroll{display:flex}
<!-- Begin MailChimp Signup Form -->
<div id="mc_embed_signup">
<form action="https://julienkozak.us14.list-manage.com/subscribe/post?
u=f46b7a895f8d332e0127067ad&id=4fbc88f22f" method="post" id="mc-
embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_blank" novalidate>
<div id="mc_embed_signup_scroll">
<div class="mc-field-group">
<input type="email" value="" name="EMAIL" class="required email" id="mce-
EMAIL" placeholder="e-mail address">
</div>
<div id="mce-responses" class="clear">
<div class="response" id="mce-error-response" style="display:none">
</div>
<div class="response" id="mce-success-response" style="display:none">
</div>
</div>
<!-- real people should not fill this in and expect good things -
do not remove this or risk form bot signups-->
<div style="position: absolute; left: -5000px;" aria-hidden="true"><input type="text" name="b_f46b7a895f8d332e0127067ad_4fbc88f22f" tabindex="-1" value=""></div>
<div class="clear"><input type="submit" value="Get Updates" name="subscribe" id="mc-embedded-subscribe" class="button"></div>
</div>
</form>
</div>
Im using bootstrap grid to build a responsive menu and a section that has a search form.But I dont understand why there are some issues in the layout relative to margins and paddings as you can see here: http://jsfiddle.net/ya08jsfy/1/.
In the header area the logo h1 is not aligned vertically at center.
Then there is a white space between the header area and the search section, do you know why? Adding some padding to the .Search div seems to solve this, but why the padding is needed? Why the .Search div by default dont appears next to the header?
Then in the search form I want the input next to the button wihout any space but its not working and also, even with box-sizing:border-box, the input is not occupying the full width because the yellow background appears.
Do you know how to fix this in a way that work in another sections so the content is aligned at center with the same padding in all sections.
html:
<header>
<div class="container">
<div class="row">
<div class="header_nav">
<div class="col-xs-6 col-sm-3">
<h1 class="header__logo">Logo</h1>
</div>
<div class="col-xs-6 col-sm-9">
<a class="nav_mobile_btn hidden-sm hidden-md hidden-lg"><i class="fa fa-bars" aria-hidden="true"></i></a>
<ul class="nav hidden-xs">
<li class="nav__item">Item 1</li>
<li class="nav__item">Item 2</li>
<li class="nav__item">Item 3</li>
<li class="nav__item">Item 1</li>
<li class="nav__item"> Item 4</li>
</ul>
</div>
</div>
</div>
</div>
</header>
<section class="Search">
<h1>Search</h1>
<form action="/signup" method="post">
<div class="row">
<p class="col-xs-10" style=background:yellow;>
<input type="text" name="first_name">
</p>
<p class="col-xs-2">
<button type="submit">Search</button>
</p>
</div>
</form>
</section>
CSS:
* {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
*:before,
*:after {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
input,textarea,select{
display: block;
padding: 15px;
width: 100%;
outline: 0;
border: 0;
}
header{
border-bottom: 1px solid red;
background-color:orange;
}
.header_nav {
display: flex;
align-items: center;
}
.header__logo{
color:green;
}
.nav {
display: flex;
align-items: center;
justify-content: flex-end;
}
.nav__item {
padding: 0 15px;
a {
font-weight: 600;
font-size: em(15px);
color: brown;
&:hover {
text-decoration: none;
}
}
&:last-of-type{
padding-right: 0;
}
}
.nav_mobile_btn{
font-size: em(30px);
color:$greypp;
float: right;
}
.Search{
background-color: green;
h1{
color: #fff;
text-align: center;
font-size: 1em;
}
}
button{padding:15px;}
Bootstrap css comes with some default margins and paddings to tags like h1 to h6 and p. In your case h1 has a margin top of 20px and bottom of 10px thats why logo is not vertically aligned. You can set headings and paragraphs margin to 0 and override bootstrap styles.
For proper alignment and sizing of buttons inside inputs use this code instead.
<div class="input-group">
<input type="text" class="form-control" placeholder="Search for...">
<span class="input-group-btn">
<button class="btn btn-secondary" type="button">Go!</button>
</span>
</div>
It causes that h1(Logo) to have a different margin on top and bottom. The solution is simple, just set the same margin for both.
h1{
margin-top:0px;
margin-bottom:0px
}
The gap between header area and search section comes from the margin of h1(Search). The solution is to set the margin of that h1(Search) to zero.
h1{
margin-top:0px;
}
It causes bootstrap to set every column to have a padding of 15px on both left and right side. The solution is to override bootstrap style:
[class*="col-"]{
padding:0px;
If you don't want to override all bootstrap columns, create your own class then.
I have an image that takes up the fold, below a fixed nav. I Want to vertical align: middle the #fold-text and chevron over the image.
html markup:
<div class="row">
<img class="background-image" src="images/1400px_splash.jpeg">
<div id="fold-container">
<div id="fold-text">
Sign up to learn about upcoming changes!
</div>
<div class="fa fa-chevron-down"></div>
</div>
</img>
</div>
This CSS below usually works when I want to center one div within another, but not luck on this (maybe because the img height is set to "auto" ? ) . Can anyone tell me how to correct this?
.background-image {
height: auto;
width: 100%;
display: table;
}
#fold-container {
display: table-cell;
vertical-align: middle;
}
#fold-text {
font-size: 1.6em;
font-weight: bold;
background-color: rgba(black, 0.3);
color: white;
display: table-cell;
}
.fa.fa-chevron-down {
z-index: 500;
color:white;
text-align: center;
font-size: 2em;
font-weight: normal;
display: table-cell;
}
Your desired markup:
<div class="row">
<img class="background-image" src="images/1400px_splash.jpeg">
<div id="fold-container">
<div id="fold-text">
Sign up to learn about upcoming changes!
</div>
<div class="fa fa-chevron-down"></div>
</div>
</img>
</div>
... is not valid HTML. <img> tags don't contain any other markup, so what the browser sees is more like this:
<div class="row">
<!-- note the self closing img tag -->
<img class="background-image" src="images/1400px_splash.jpeg"/>
<div id="fold-container">
<div id="fold-text">
Sign up to learn about upcoming changes!
</div>
<div class="fa fa-chevron-down"></div>
</div>
<!-- </img> don't know what to do with this, because img tags close themselves -->
</div>
What you need to do is more like this:
<div class="row">
<div id="fold-container">
<div id="fold-text">
Sign up to learn about upcoming changes!
</div>
<div class="fa fa-chevron-down"></div>
<img class="background-image" src="images/1400px_splash.jpeg"/>
</div>
</div>
... and just make sure the appropriate stylings are added to your elements to position them appropriately.