I am attempting to have our opening days aligned to the left and our hours aligned to the right but sit in the center of our navigation bar. I am using squarespace. Currently I have it like this but not sufficiently close and on the mobile version it looks silly, any help would be appreciated thanks.
HTML Code Block:
<center>
<div class="contactfield">
<div class="contact">
<div class="date">Mon-Wed</div><div class="time">5PM - 11PM</div>
<div class="date">Thu</div><div class="time">12PM - 11PM</div>
<div class="date">Fri-Sat</div><div class="time">12PM - 1AM</div>
<div class="date">Sun</div><div class="time">12PM - 11PM</div>
</div></center>
<center> <span><img class=“sm_icons“ src="https://static1.squarespace.com/static/615e86638bf80f2683975e8f/t/630ff2cac2a9b76708e4df5d/1661989587824/phone.png" width= 12px ></span> 03 8591 3000
<div class="smaller">hello#trinitystkilda.com</div>
</center>
CSS:
p.smaller {
line-height: 0px;
}
p.smaller{
margin-top:-25px;
}
.navbar{
text-align:center;
.header-nav-list{
width: 100%;
max-width:800px;
margin:0 auto;
justify-content:space-evenly;
}
}
p.contact {
line-height: 0px;
}
p.contact{
margin-top:0px;
}
.contact .date{
font-size: 14px;
width:30%;
display:inline-block;
box-sizing:border-box;
text-align:left;
}
.contact .time{
font-size: 14px;
text-align:right;
padding-right:10px;
width:70%;
display:inline-block;
box-sizing:border-box;
}
p.email {
line-height: 0px;
}
p.email{
margin-top:5px;
color: white;
}
Images:
Mobile
Web
Just give your date & time class with some wrapper (Heres I gave wrapper with class name .date-time), and use flex to make the child center.
.contact {
display: flex;
flex-direction: column;;
}
.date-time {
display: flex;
justify-content: space-around;
}
.date, .time {
width: 50%;
text-align: center;
}
<div class="contact">
<div class="date-time">
<div class="date">Mon-Wed</div>
<div class="time">5PM - 11PM</div>
</div>
<div class="date-time">
<div class="date">Thu</div>
<div class="time">12PM - 11PM</div>
</div>
<div class="date-time">
<div class="date">Fri-Sat</div>
<div class="time">12PM - 1AM</div>
</div>
<div class="date-time">
<div class="date">Sun</div>
<div class="time">12PM - 11PM</div>
</div>
</div>
Related
This question already has answers here:
How do I center floated elements?
(12 answers)
Closed 1 year ago.
I am having an issue trying to centre the elements within the .footer-strip-container on the page. It doesn't seem to shift to the centre unless I add some side padding for #text-5 element and I am not sure why that is. I want the elements to be centred if the screen is max 1364.
Below is my html and CSS:
#text-5{
width:100% !important;
}
.footer_wrap_inner > .content_wrap{
width:100% !important;
}
.footer-strip-container{
width:100%;
}
.float-child{
width:50%;
float:left;
}
.footer-strip-col1{
text-align:left;
}
.float-text{
font-size:24px;
padding-left:50px;
}
.float-text,
.float-img{
float:left;
}
.footer-strip-col2{
text-align:right;
}
#media only screen and (max-width: 1364px) {
.float-child {
width:100%;
float:none;
clear:right;
}
}
<aside id="text-5" class="widget_number_7 column-1_3 widget widget_text">
<div class="textwidget">
<div class="footer-strip-container">
<div class="float-child">
<div class="footer-strip-col1-text">
<img src="https://shop.balancecoffee.co.uk/wp-content/uploads/2021/07/ezgif.com-gif-maker-1.gif" alt="Join Balance" class="float-img"><br>
<span class="float-text">Join Balance and get 20% off your first order</span>
</div>
<p></p>
</div>
<div class="float-child">
<div class="klaviyo-form-Re6W9v footer-strip-col2 klaviyo-form form-version-cid-2"></div>
</div>
</div>
</div>
</aside>
All you need to do is to add to replace your .footer-strip-container code with this
.footer-strip-container{
width: 50%;
margin: auto;
}
and your div would be centered
if you want your parent container to be 100%
then use this code
#media only screen and (max-width: 1364px) {
.float-child {
width: 50%;
float: none;
clear: right;
margin: auto;
}
}
You shouldn't use float use flexbox instead
.footer-strip-container {
display : flex;
justify-content : center;
width: 100%;
}
.float-child {
max-width : 50%;
}
.footer-strip-col1 {
text-align: left;
}
.footer-strip-col1-text {
display : flex;
align-items : center;
}
.float-text {
font-size: 24px;
padding-left: 50px;
}
.footer-strip-col2 {
text-align: right;
}
<aside id="text-5" class="widget_number_7 column-1_3 widget widget_text">
<div class="textwidget">
<div class="footer-strip-container">
<div class="float-child">
<div class="footer-strip-col1-text">
<img src="https://shop.balancecoffee.co.uk/wp-content/uploads/2021/07/ezgif.com-gif-maker-1.gif"
alt="Join Balance" class="float-img">
<span class="float-text">Join Balance and get 20% off your first order</span>
</div>
<p></p>
</div>
<div class="float-child">
<div class="klaviyo-form-Re6W9v footer-strip-col2 klaviyo-form form-version-cid-2"></div>
</div>
</div>
</div>
</aside>
display:flex will reduce a lot of unnecessary CSS code.
Here's a complete guide on Flexbox: https://css-tricks.com/snippets/css/a-guide-to-flexbox/
.footer-strip-col1-text {
display: flex;
align-items: center;
justify-content: center;
flex-wrap: wrap;
}
.float-text {
font-size: 24px;
padding-left: 50px;
text-align: center;
}
/*define media query size, for demonstration I used 991px*/
#media only screen and (max-width: 991px) {
.footer-strip-col1-text {
flex-direction: column;
}
.float-text {
padding-left: 0;
padding-top: 20px;
}
}
<aside id="text-5" class="widget_number_7 column-1_3 widget widget_text">
<div class="textwidget">
<div class="footer-strip-container">
<div class="float-child">
<div class="footer-strip-col1-text">
<img src="https://shop.balancecoffee.co.uk/wp-content/uploads/2021/07/ezgif.com-gif-maker-1.gif" alt="Join Balance" class="float-img">
<span class="float-text">Join Balance and get 20% off your first order</span>
</div>
<p></p>
</div>
<div class="float-child">
<div class="klaviyo-form-Re6W9v footer-strip-col2 klaviyo-form form-version-cid-2"></div>
</div>
</div>
</div>
</aside>
I am currently working on a school assignment where we can only use HTML + CSS (and PHP to include repeated elements, navbar + footer in this case).
For the footer I would like to place 3 elements in the 'Left' - 'Center' - 'Right' part of the footer.
Left: A newsletter bar to enter e-mail with a SIGN UP button
Center: 3 line text - Address, contact, opening hours.
Right: 2 icons - 1 for school and 1 for business'.
This is my code:
HTML:
<footer>
<div class="footer">
<p class="left">Sign up botton here</p>
<p class="right">School - business here</p>
<p class="centered">3 lines with address, contact info, and opening hours.</p>
</div>
CSS:
.left{
text-align:left;
float:left;
}
.right{
float:right;
text-align:right;
}
.centered{
text-align:center;
}
.footer {
position:absolute;
bottom:0;
width:100%;
height:60px;
background:#052D48;
}
.footer p {
color: #fff;
font-size: 8px;
}
How would I go about this? I've been reading and trying stuff for hours, but I just get more confused.
i.imgur.com/6IFJnxF.png Here is a picture of what I have in mind
Hope someone can help me in the right direction, thanks a lot!
Using flexbox and wrapping everything inside a container and a row with a 100% width. Then divide each block by X percentage. I changed the p tags with an unordered list.
.row{
width: 100%;
display: flex;
flex-wrap: wrap;
}
.left{
width: 33%;
height: 40px;
}
.right{
width: 33%
}
.right ul{
list-style: none;
color: white;
}
.middle{
width: 33%
}
.centered{text-align:center;}
.flex{
display: flex;
justify-content: center;
flex-wrap: wrap;
}
.flex-column{
display: flex;
flex-direction: column;
}
.footer {
padding: 20px 10px;
background:#052D48;
}
.footer p{
font-size: 1.3em;
color: #ffffff;
}
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
<footer>
<div class="footer">
<div class="row">
<div class="left flex">
<input type="text" class="" placeholder="Email">
<input type="submit" class="" value="Submit">
</div>
<div class="right centered ">
<ul class="flex-column">
<li><i class="fa fa-map-marker" aria-hidden="true"></i> Address.</li>
<li><i class="fa fa-phone" aria-hidden="true"></i> Contact Info</li>
<li><i class="fa fa-clock-o" aria-hidden="true"></i> Opening Hours.</li>
</ul>
</div>
<div class="middle centered">
<p class="">School - business here</p>
</div>
</div>
</div>
</footer>
I would recommend taking the class off of footer and just use the footer tag to target the parent container. Then I would use div tags for each section instead of p tags, putting p tags inside the div. And my last recommendation, although your professor will think you're cheating, is to use flexbox. Enjoy.
Also the box-sizing: border-box; is for the padding I added to the footer so it will still be width: 100%; instead of 100% + 40px
* {
box-sizing: border-box;
}
.left {}
.centered {}
.centered p {}
.right {}
footer {
display: flex;
justify-content: space-between;
align-items: center;
padding: 0 20px;
position: absolute;
bottom: 0;
width: 100%;
height: 60px;
background: #052D48;
}
footer p {
margin: 0;
color: green;
font-size: 8px;
}
<footer>
<div class="left">
<p>Sign up botton here</p>
</div>
<div class="centered">
<p>1 line</p>
<p>2 line</p>
<p>3 line</p>
</div>
<div class="right">
<p>School - business here</p>
</div>
</footer>
here is one idea.
https://jsfiddle.net/gztLhdk4/2/
you can customize it more based on your needs.
<footer>
<div class="footer">
<div class="left padd">
<p>
Sign up botton here
</p>
<p>
<input type="text"> <button>sign up </button>
</p>
</div>
<div class="centered padd">
<p>
rttertertert<br>
gereryrt ytyt<br>
tryryrytru
</p>
</div>
<div class="right padd">
<div>
school
</div>
<div>
business
</div>
</div>
</div>
</footer>
.left{
text-align:left;
float:left;
}
.right{
float:right;
text-align:right;
}
.centered{
text-align:center;width:50%;float:left;
}
.footer {
position:absolute;
bottom:0;
width:100%;
height:60px;
background:#052D48;
}
.footer p {
color: #fff;
font-size: 8px;
}
.padd{padding:5px;color:#fff;}
I have a block of cards which are arranged within a container like so:
<div class="projekt_wrapper">
<div class="projekt_card">
<div class="projekt_breadcrumb"><span>Headline</span><span>The title</span></div>
<div class="projekt_container">
<h1>Title again - for you</h1>
<p>Caption for the image</p></div>
</div>
<div class="projekt_card">
<div class="projekt_breadcrumb"><span>Headline</span><span>The title</span></div>
<div class="projekt_container">
<h1>Title again - for you</h1>
<p>Caption for the image</p></div>
</div>
<div class="projekt_card">
<div class="projekt_breadcrumb"><span>Headline</span><span>The title</span></div>
<div class="projekt_container">
<h1>Title again - for you</h1>
<p>Caption for the image</p></div>
</div>
</div>
And I want/do arrange these cards with flexbox like so:
.projekt_wrapper{
width:91.68vw;
display: flex;
flex-direction: column;
flex-wrap: wrap;
height: 200vh;
max-height: 8000px;
font-size: 0;
}
.projekt_card{
width:50%;
margin:0;
}
.projekt_card *{
max-width:100%;
}
.projekt_container{
background: url(https://dl.dropboxusercontent.com/u/1207766/projekte-digitalready.jpg) no-repeat;
background-size:cover;
min-height:100vh;
padding-top:20vh;
}
.projekt_container h1, .projekt_container p{
color:red;
text-align:center;
max-width:600px;
margin:0 auto;
padding-bottom: 2vh;
}
.projekt_container p{
border-bottom:1px solid red;
padding-bottom:5vh;
}
.projekt_container img{
margin:8vh 48%;
max-width:4vw;
}
You may also have a look at it right here: http://codepen.io/daiaiai/pen/mRGdaR
And there you'll see the problem that I have by them inner-blocks not breaking into a new line correctly. What do I need to do to make it work correctly?
Thanks a lot!
So my logic of Div ID's and Classes must be WAY off.
Heres whats going on:
As you can see the blocks which say PS don't align center with the slider (Which is inside a container.
Here is my css:
/*Front Page Buttons */
#frontpage-Button-Cont {
height: 350px;
}
.button-cont {
width: 175px;
float: left;
margin-left: 10px;
margin-top: 10px;
height: 250px;
}
.thumbnail {
color: #fff;
font-size: 5em;
background: #1f4e9b;
width: 175px;
height: 135px;
text-align: center;
}
.pheader {
color: #DC143C;
min-width: 175px;
text-align: center;
}
.paragraph {
text-align: center;
}
#Align-content {
margin: 0 auto;
}
And here is the html:
<div id="frontpage-Button-Cont">
<div id="Align-content">
<div class="button-cont">
<div class="thumbnail">
PS
</div>
<div class="paragraph">
<div class="pheader">
HEADER
</div>
<p>dadaasdasdadadad
</div>
</div>
<div class="button-cont">
<div class="thumbnail">
PS
</div>
<div class="paragraph">
<div class="pheader">
HEADER
</div>
<p>dadaasdasdadadad
</div>
</div>
<div class="button-cont">
<div class="thumbnail">
PS
</div>
<div class="paragraph">
<div class="pheader">
HEADER
</div>
<p>dadaasdasdadadad
</div>
</div>
<div class="button-cont">
<div class="thumbnail">
PS
</div>
<div class="paragraph">
<div class="pheader">
HEADER
</div>
<p>dadaasdasdadadad
</div>
</div>
</div>
</div>
My theory is that I'm using classes incorrectly?
Thanks.
You can Add this to your CSS
#frontpage-Button-Cont {
width:100%;
}
#Align-content {
display:table;
}
With this your margin:o auto can work
View This Demo http://jsfiddle.net/VGPeW/
You need to make sure that the containing div (in this case frontpage-Button-Cont) is the same width as your slider above it. Then add the property text-align:center to the container. That should fix your issue.
I'm trying to make this kind of responsive design with CSS.
It basically should be 600px width when there's enough space to show whole length.
When not, it folds, then right partial come appears on the bottom of left partial.
I'm struggling how to archive this.
This is DEMO that I could go this far
http://jsfiddle.net/a7Fkj/5/
HTML
<div class="table_row">
<div class="left_partial">
<div class="StoreName">Walmart Store</div>
<div class="Location">Located in California</div>
</div>
<div class="right_partial">
<div class="store_icon"><img src="https://twimg0-a.akamaihd.net/profile_images/616833885/walmart_logo_youtube.jpg"><div>
<div class="person1">John Smith<div>
<div class="person2">Mike Tailor<div>
<div class="person3">Jessica Swan<div>
</div>
</div>
CSS
div.table_row{
min-width: 300px;
margin-bottom: 30px;
}
div.left_partial{
width: 300px;
}
div.right_partial{
width: 300px;
}
div.StoreName{
background-color: #000000;
color: #FFFFFF;
}
div.Location{
}
div.store_icon{
width: 60px;
height: 60px;
}
div.person1{
}
div.person2{
}
div.person3{
}
You don't need media queries for this design- you can use inline-block to collapse the layout when the browser is resized.
HTML:
<div class="table_row">
<div class="left_partial">
<div class="StoreName">Walmart Store</div>
<div class="Location">Located in California</div>
</div>
<div class="right_partial">
<div class="store_icon"><img src="https://twimg0-a.akamaihd.net/profile_images/616833885/walmart_logo_youtube.jpg" /></div>
<div class="people">
<div class="person">John Smith</div>
<div class="person">Mike Tailor</div>
<div class="person">Jessica Swan</div>
</div>
</div>
</div>
CSS:
div.table_row{
min-width: 300px;
margin-bottom: 30px;
}
div.left_partial{
width: 300px;
display:inline-block;
vertical-align:top;
}
div.right_partial{
width: 300px;
display:inline-block;
vertical-align:top;
margin-bottom:30px;
}
div.StoreName{
background-color: #000000;
color: #FFFFFF;
}
div.Location{
}
div.store_icon{
width: 60px;
height: 60px;
display:inline-block;
vertical-align:top;
}
div.store_icon img{
width:100%;
height:100%;
}
div.people{
display:inline-block;
vertical-align:top;
height:60px;
width:234px;
}
jsfiddle: http://jsfiddle.net/kmMEM/
This will collapse the design when the browser is resized- I added a 30px bottom margin to your right_partial to ensure the list stacks correctly.