Removing space between 3 HTML columns - html

In the code below I have 3 col-md-4 that I want to reduce the space between to about 25px. I've tried reducing the margin between them along with increasing the padding on the left and right side of the first and last column respectively. The problem with this approach is that when the window size is manipulated it makes the image columns offset because of the increased padding.
HTML:
<div class="cards">
<div class="container">
<h2>
Our Expertise.
</h2>
</div>
<div class="row">
<div class="col-md-4">
<!-- <img> -->
<!-- <img> -->
<!-- <img> -->
</div>
<div class="col-md-4">
<!-- <img> -->
<!-- <img> -->
<!-- <img> -->
</div>
<div class="col-md-4">
<!-- <img> -->
<!-- <img> -->
<!-- <img> -->
<!-- <img> -->
</div>
</div>
</div>
CSS:
html, body {
margin: 0;
padding: 0;
font-family: 'Libre Baskerville', sans-serif;
}
.first {
padding-left: 200px !important;
}
.last {
padding-right: 200px !important;
}
.container {
max-width: 980px;
margin: 0 auto;
}
.header {
padding-top: 20px;
}
.header h1 {
font-size: 20px;
}
.nav li {
margin: 0px;
border: 0px;
}
.nav li a {
color: #333;
}
.jumbotron {
background-color: transparent;
padding-top: 100px;
padding-bottom: 100px;
}
.jumbotron h2 {
font-size: 50px;
}
.jumbotron h2 span {
color: #ffc200;
}
.banner {
background-color: #333;
height: 140px;
color: white;
text-align: center;
padding-top: 30px;
}
.cards {
background-color: #FFC200;
text-align: center;
}
.cards img {
margin-bottom: 25px;
padding: auto;
}
.cards h2 {
margin-top: 20px;
margin-bottom: 80px;
}
#media (max-width: 992px) {
.col-md-4 {
margin: 0 auto 0;
text-align: center;
width: 100%;
}
.cards img {
width: 60%;
}
}
#media (max-width: 500px) {
.header h1 {
text-align: center;
}
.nav li {
text-align: center;
width: 100%;
}
.cards img {
width: 100%;
}
}
There are suppose to be images in the columns but because I don't have 10 rep points it wont let me post them.

Just change the default column padding. You need to keep the total space between the columns an even number, so 24 would be good, you would simply change the default column padding from 15px to 12px and override the negative margin on the row as well:
.row {
margin-left: -12px!important;
margin-right: -12px!important;
}
div[class*='col-'] {
padding-left: 12px;
padding-right: 12px;
}
.inner {
border:1px solid black;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
<div class="cards">
<div class="container">
<h2>
Our Expertise.
</h2>
</div>
<div class="row">
<div class="col-md-4">
<div class="inner">Column 1</div>
</div>
<div class="col-md-4">
<div class="inner">Column 2</div>
</div>
<div class="col-md-4">
<div class="inner">Column 3</div>
</div>
</div>
</div>

Related

Footer at bottom of page OR below content, whichever is lower

I have looked and looked, and can't find a solution to this that works (have tried LOTS!). I have a fixed header, and two columns that I want to expand with content, but want to appear full height if low on content. Then a footer that I want to appear either below the content (when lots) or at the bottom of the page. With the below HTML/CSS, the footer appears just off the viewscreen, but even worse, for some reason if I have enough text to push off the screen, my footer disappears!!
Edited: I figured it out. Yay!! on to next step.
HTML - EDITED
<header>
<div class="fixed-top">
<div style="height: 10px; background: #27AAE1;"></div>
<div id="Top_Bar" class="row">
<div class="col-sm-2">
<a><img src="images/nmdlogo.png" height=80px;></a>
</div>
<div class="col-sm-10">
<h1 "text-align=center";>Admin Panel</h1>
</div>
</div>
<div style="height: 10px; background: #27AAE1;"></div>
</div>
</header>
<main class="Site-content">
<div class="container-fluid h-100">
<div class="row h-100">
<div id="Menu_Panel" class="col-sm-2"><!-- Left Side Menu Area -->
Menu
</div><!-- End of col-sm-2 Left Side Menu Area -->
<div id="Main_Panel" class="col-sm-10"><!-- Main Area -->
Main Panel<br>
</div><!-- End col-sm-10 Main Area -->
</div><!-- End of Row -->
</div><!-- End of Container -->
</main>
<footer>
<div class="customHr"></div>
<div class="col-sm-10 offset-sm-2">
<span>Text Here</span><br>
<a style="color: white; text-decoration: none; cursor: pointer; font-weight: bold;" href="#">Link Name</a>
</div>
<div class="customHr"></div>
<div style="height: 10px; background: #27AAE1;"></div>
</footer>
CSS - EDITED
.Site {
display: flex;
min-height: 100vh;
flex-direction: column;
background-color: #2f4050;
}
.Site-content {
flex: 1;
margin-top: 120px;
}
#Menu_Panel{
background-color: #d10e1e;
}
#Main_Panel{
background-color: #ffffff;
}
#Top_Bar{
text-align: center;
color:#ffffff;
img-align: center;
background-color: #2f4050;
padding-top: 10px;
padding-bottom: 10px;
}
footer {
color:#ffffff;
text-align: center;
}
.customHr {
border-bottom: 1px solid #9fb1c2;
margin-top: 10px;
margin-bottom: 10px;
font-size: .8em;
padding-top: 5x;
padding-bottom: 5px;
}
I imagine you're looking for a footer that sticks to the bottom of your page than?
Edited:
Following css (based on your original) should give you what you're looking for
* {
margin: 0;
}
html {
height: 100%;
box-sizing: border-box;
}
*,
*:before,
*:after {
box-sizing: inherit;
}
body {
background-color: #2f4050;
position: relative;
margin: 0;
padding-bottom: 6rem;
min-height: 100%;
}
#Menu_Panel {
background-color: #d10e1e;
margin-top: 120px;
}
#Main_Panel {
background-color: #ffffff;
margin-top: 120px;
}
#Fixed_Top {
position: fixed; /* Set the navbar to fixed position */
top: 0;
}
#Top_Bar {
text-align: center;
color: #ffffff;
img-align: center;
background-color: #2f4050;
padding-top: 10px;
padding-bottom: 10px;
}
.footer {
color: #ffffff;
text-align: center;
width: 100%;
position: absolute;
right: 0;
bottom: 0;
left: 0;
}
.customHr {
border-bottom: 1px solid #9fb1c2;
margin-top: 10px;
margin-bottom: 10px;
font-size: .8em;
padding-top: 5x;
padding-bottom: 5px;
}

CSS and html layout

I have this html and css layout. I want to make it when reaching tablet with media query and phone to show like in those 2 images. So I have in normal (desktop mode) 4 products all of them in the same line. When the view reaches tablet - 1199 pixels I want those 4 products to be each 2 on a separate line, so 2 lines with 2 products. On the phone mode 768 pixels I want each product to be on its line with the width full like the wrapper.
Here is the code :
body {
margin: 0px;
padding: 0px;
}
/* Header */
.header {
background-color: yellow;
width: 100%;
margin: 0 auto;
}
.wrapper {
max-width: 1200px;
margin: 0 auto;
}
.logo {
background-color: grey;
width: 150px;
height: 50px;
margin-top: 20px;
float: left;
}
.info {
background-color: grey;
width: 285px;
height: 50px;
margin-top: 20px;
float: right;
}
.clear {
clear: both;
}
.menu {
background-color: grey;
width: 1200px;
height: 50px;
margin-top: 20px;
}
/* */
/* Nav-Bar */
.nav-bar {
background-color: lightgray;
width: 1200px;
height: 340px;
margin-top: 20px;
}
/* */
/* Product grid */
.product1,
.product2,
.product3 {
background-color: lightgray;
width: 285px;
height: 320px;
margin-top: 20px;
margin-right: 20px;
float: left;
}
.product4 {
background-color: lightgray;
width: 285px;
height: 320px;
margin-top: 20px;
float: left;
}
/* */
/* Bottom Part */
.content-area {
background-color: lightgray;
width: 100%;
height: 420px;
margin-top: 20px;
}
/* */
/* Footer */
.footer-area {
background-color: gray;
width: 100%;
height: 50px;
margin-top: 20px;
}
/* */
/* Responsive */
#media screen and (max-width: 1199px) {
.product1,
.product2,
.product3,
.product4 {
display: none;
}
}
<!DOCTYPE html>
<html>
<head>
<title>Home View</title>
<link rel="stylesheet" type="text/css" href="../style/homestyle.css">
</head>
<body>
<!-- Header -->
<div class="header">
<div class="wrapper">
<div class="logo"></div>
<div class="info"></div>
<div class="clear"></div>
<div class="menu"></div>
</div>
</div>
<!-- -->
<!-- NavBar -->
<div class="header">
<div class="wrapper">
<div class="nav-bar"></div>
<div class="clear"></div>
</div>
</div>
<!-- -->
<!-- Product Grid -->
<div class="wrapper">
<div class="def1">
<div class="product1"></div>
</div>
<div class="def2">
<div class="product2"></div>
</div>
<div class="def3">
<div class="product3"></div>
</div>
<div class="def4">
<div class="product4"></div>
</div>
<div class="clear"></div>
</div>
<!-- -->
<!-- Bottom Part -->
<div class="wrapper">
<div class="content-area"></div>
</div>
<!-- Footer -->
<div class="header">
<div class="wrapper">
<div class="footer-area"></div>
</div>
</div>
</body>
</html>
The CSSTablet :
I attached the images needed for the layout. Please help!
First you add the view port element to Head of the HTML page.
<meta name="viewport" content="width=device-width, initial-scale=1.0">
Ref. link - https://www.w3schools.com/css/css_rwd_viewport.asp
Then Remove fixed width's from .menu and .nav-bar classes and add as max-width.
.menu {
background-color: grey;
max-width: 1200px;
height: 50px;
margin-top: 20px;
}
.nav-bar {
background-color: lightgray;
max-width: 1200px;
height: 340px;
margin-top: 20px;
}
And also you need to wrap your "Product slots" using "div".
(I used class called "wrapper-inner")
<!-- Product Grid -->
<div class="wrapper">
<div class="wrapper-inner">
<div class="def1">
<div class="product1"></div>
</div>
<div class="def2">
<div class="product2"></div>
</div>
<div class="def3">
<div class="product3"></div>
</div>
<div class="def4">
<div class="product4"></div>
</div>
<div class="clear"></div>
</div>
</div>
<!-- -->
Then after you can add required CSS media queries.
/* Responsive */
#media all and (max-width: 1199px) {
.wrapper-inner {
margin: 0 -20px;
background: orange;
padding: 0 20px;
}
.def1, .def2, .def3, .def4 {
width: 50%;
padding: 20px;
float: left;
}
.product1, .product2, .product3, .product4 {
width: 100%;
margin: 0 0;
}
}
#media all and (max-width: 768px) {
.def1, .def2, .def3, .def4 {
width: 100%;
padding: 20px;
float: left;
}
}
You are correct in using media queries. In those you can f.e. set the width of your elements like this:
#media screen and (max-width: 1199) {
.product { // you can write .product1, .product2,... but I would suggest creating this new class, as none of those images really need their own css
max-width: 25%; //this will change for tablet and mobile to 50% and 100%
}
}
Now do that for all modes that you want.
Also note that instead of setting a margin-right you could use flexbox with justify-content: space-between in the wrapper; Otherwise you will have to remove those margins for different screen sizes.

why the h1 tag for the clock is not completely centered vertically

I'm working on a pomodoro clock that the h1 tag displaying the clock timer is not centered vertically (center of page). how could I center the text vertically without losing horizontal alignment? Also if someone can suggest how could I bring the - (minus) and + (plus) signs inside the controls closer to the middle without moving the text.
body {
background-color: #545454;
}
.title {
margin: auto;
text-align: center;
font-size: 30px;
}
.container {
text-align: center;
}
h2 {
font-size: 50px;
margin: 0 0 0 0;
}
.clockContainer {
position: relative;
text-align: center;
}
.timer {
margin: 0 50px;
margin-top: 70px;
text-align: center;
border: solid black 1px;
font-size: 44px;
width: 500px;
height: 200px;
display: inline-block;
}
.controlContainer {
position: absolute;
text-align: center;
width: 100px;
display: inline-block;
}
.control {
width: 100px;
height: 100px;
border-radius: 100px;
border: solid black 1px;
text-align: center;
margin-bottom: 20px;
}
.button {
margin-top: 30px;
}
.hide {
display: none;
}
.time {
margin-top: 5px;
margin-bottom: 5px;
font-size: 20px;
}
.ticker {
display: inline-block;
font-size: 30px;
margin-top: 0px;
}
.minus {
margin-right: 10px;
}
.plus {
margin-left: 10px;
}
<div class="container">
<!-- header title -->
<div class="title primary-text">
<h1>Pomodoro Clock</h1>
</div>
<!-- clock container -->
<div class="clockContainer">
<h2>Session</h2>
<!-- timer / clock -->
<div class="timer">
<h1 class="display">23:59</h1>
</div>
<!-- this section for controlling clock -->
<div class="controlContainer">
<div class="control">
<div class="button title">Start</div>
<div class="button hide title">Stop</div>
</div>
<div class="control">
<h3 class="time">30</h3>
<h3 class="title work">Work</h3>
<h3 class="minWork ticker minus">-</h3>
<h3 class="plusWork ticker plus">+</h3>
</div>
<div class="control">
<h3 class="time">10</h3>
<h3 class="title break">Break</h3>
<h3 class="minBrake ticker minus">-</h3>
<h3 class="plusBrake ticker plus">+</h3>
</div>
</div>
</div>
</div>
Your question is not totally clear but try applying this to the element:
position: relative;
top: 50%;
transform: translateY(-50%);
h1 {
vertical-align: middle;
}
This will align the h1 the way you want I believe.
Just remove height for .timer to center h1. Due to fixed height, h1 is not centered because it is bigger than 200px. If you want to decrease height of .timer just decrease h1's margin-top and margin-bottom.
To move + and - closer to middle decrease margin-top values for .ticker (e.g. from 0 to -5px). Demo:
body {
background-color: #545454;
}
.title {
margin: auto;
text-align: center;
font-size: 30px;
}
.container {
text-align: center;
}
h2 {
font-size: 50px;
margin: 0 0 0 0;
}
.clockContainer {
position: relative;
text-align: center;
}
.timer {
margin: 0 50px;
margin-top: 70px;
text-align: center;
border: solid black 1px;
font-size: 44px;
width: 500px;
display: inline-block;
}
.controlContainer {
position: absolute;
text-align: center;
width: 100px;
display: inline-block;
}
.control {
width: 100px;
height: 100px;
border-radius: 100px;
border: solid black 1px;
text-align: center;
margin-bottom: 20px;
}
.button {
margin-top: 30px;
}
.hide {
display: none;
}
.time {
margin-top: 5px;
margin-bottom: 5px;
font-size: 20px;
}
.ticker {
display: inline-block;
font-size: 30px;
margin-top: -5px;
}
.minus {
margin-right: 10px;
}
.plus {
margin-left: 10px;
}
<div class="container">
<!-- header title -->
<div class="title primary-text">
<h1>Pomodoro Clock</h1>
</div>
<!-- clock container -->
<div class="clockContainer">
<h2>Session</h2>
<!-- timer / clock -->
<div class="timer">
<h1 class="display">23:59</h1>
</div>
<!-- this section for controlling clock -->
<div class="controlContainer">
<div class="control">
<div class="button title">Start</div>
<div class="button hide title">Stop</div>
</div>
<div class="control">
<h3 class="time">30</h3>
<h3 class="title work">Work</h3>
<h3 class="minWork ticker minus">-</h3>
<h3 class="plusWork ticker plus">+</h3>
</div>
<div class="control">
<h3 class="time">10</h3>
<h3 class="title break">Break</h3>
<h3 class="minBrake ticker minus">-</h3>
<h3 class="plusBrake ticker plus">+</h3>
</div>
</div>
</div>
</div>

How to make a grid with images inside a div with HTML?

I am trying to make a grid of pictures with padding in between inside the main_block div. I cant get the images to aline next to eachother and then break it with a becouse they go inline. inline block does not work. I tried making a new div for these images but i cant resize the pictures nor give them padding. I tried to make the pictures resizable but without results. iut is as if something is overriding the size of the pictures. The pictures stack upon eachother and im trying to maaake a grid.
Thanks in advance for any help!
This would be the optimal solution.
Here is the fiddle
https://jsfiddle.net/q2cr9ttL/1/
<style>
body {
margin: 0;
padding: 0;
}
#header {
background-color: #ff6600;
color: white;
text-align: left;
padding: 2px;
}
#nav {
line-height: 30px;
background-color: #fff000;
height: 350px;
width: 125px;
float: left;
padding: 5px;
}
#section {
width: 350px;
float: left;
padding: 10px;
}
#footer {
background-color: #737373;
color: white;
clear: both;
text-align: center;
}
#container {
margin: auto;
width: 900px;
text-align: left;
overflow: hidden;
}
.inner_block {
display: inline-block;
text-align: center;
width: 350px;
height: 200px;
}
.main_block {
text-align: center;
width: 750px;
}
.grid_block {
display: inline-block;
text-align: center;
width: 29%px;
height:100px;
}
</style>
<meta charset="UTF-8">
<link type="text/css" rel="stylesheet" href="stylesheet.css" />
<body>
<div id="container">
<!---container--->
<div id="header">
<h1>JORDAS</h1>
</div>
<!--header-->
<div id="nav">
Etusivu
<br>
Teltat
<br>
Palvelut
<br>
Yhteistiedot
<br>
</div>
<div id="section">
<div class="main_block">
<div class="grid_block">
<img src=Grafik/basictalt.png>
</div>
<div class="grid_block">
<img src=Grafik/basictalt.png >
</div>
<div class="grid_block">
<img src=Grafik/basictalt.png>
</div>
</div><!--mainblock-->
</div>
<div id="footer">
<h3>POP-UP TELTTOJEN YKKÖNEN </h3>
</div>
<!--footer-->
</div>
<!--container-->
</body>
You could use the flex display property.
You will need to include some prefixes for cross browser compatibility.
* {
box-sizing: border-box;
}
.main_block {
display: flex;
flex-wrap: wrap;
}
.grid_block {
width: 33%;
padding: 1.4em
}
.grid_block img {
max-width: 100%
}
/* ORIGINAL STYLES */
body {
margin: 0;
padding: 0;
}
#header {
background-color: #ff6600;
color: white;
text-align: left;
padding: 2px;
}
#nav {
line-height: 30px;
background-color: #fff000;
height: 350px;
width: 125px;
float: left;
padding: 5px;
}
#section {
width: 350px;
float: left;
padding: 10px;
}
#footer {
background-color: #737373;
color: white;
clear: both;
text-align: center;
}
#container {
margin: auto;
width: 900px;
text-align: left;
overflow: hidden;
}
.inner_block {
display: inline-block;
text-align: center;
width: 350px;
height: 200px;
}
.main_block {
text-align: center;
width: 750px;
}
.grid_block {
display: inline-block;
text-align: center;
width: 29%px;
height: 100px;
}
<div id="container">
<!---container--->
<div id="header">
<h1>JORDAS</h1>
</div>
<!--header-->
<div id="nav">
Etusivu
<br>
Teltat
<br>
Palvelut
<br>
Yhteistiedot
<br>
</div>
<div id="section">
<div class="main_block">
<div class="grid_block">
<img src=http://lorempixel.com/image_output/city-q-c-640-480-9.jpg>
</div>
<div class="grid_block">
<img src=http://lorempixel.com/image_output/city-q-c-640-480-9.jpg >
</div>
<div class="grid_block">
<img src=http://lorempixel.com/image_output/city-q-c-640-480-9.jpg>
</div>
</div><!--mainblock-->
</div>
<div id="footer">
<h3>POP-UP TELTTOJEN YKKÖNEN </h3>
</div>
<!--footer-->
</div>
<!--container-->

CSS does not display background color for div tag

I put my div id="banner" and style it to give the color that matches the image but the color doesn't display. So, what should I do?
#cloud {
float: left;
padding: 0px;
margin: 0px;
}
#page {
width: 800px;
margin-right: auto;
margin-left: auto;
}
#home {
float: left;
padding-left: 30px;
padding-right: 30px;
text-align: center;
}
#banner {
background-color: #78c8f0;
}
<div id="page">
<div id="banner">
<div id="cloud">
<img src="Cloud4.gif" />
</div>
<!--cloud-->
<div id="home">
<h2>HOME</h2>
</div>
<!--home-->
</div>
<!--banner-->
</div>
<!--page-->
Since #cloud (the child of #banner) is floated, #banner essentially collapses and it acts like it doesn't have content. You can remedy this by adding overflow:auto to #banner.
#cloud {
float: left;
padding: 0px;
margin: 0px;
}
#page {
width: 800px;
margin-right: auto;
margin-left: auto;
}
#home {
float: left;
padding-left: 30px;
padding-right: 30px;
text-align: center;
}
#banner {
background-color: #78c8f0;
overflow: auto;
}
<div id="page">
<div id="banner">
<div id="cloud">
<img src="Cloud4.gif" />
</div>
<!--cloud-->
<div id="home">
<h2>HOME</h2>
</div>
<!--home-->
</div>
<!--banner-->
</div>
<!--page-->
Simply give #banner some height. See the snippet.
#banner {
background-color: #78c8f0;
height: 40px;
}
Snippet
#cloud {
float: left;
padding: 0px;
margin: 0px;
}
#page {
width: 800px;
margin-right: auto;
margin-left: auto;
}
#home {
float: left;
padding-left: 30px;
padding-right: 30px;
text-align: center;
}
#banner {
background-color: #78c8f0;
height: 40px;
}
<div id="page">
<div id="banner">
<div id="cloud">
<img src="Cloud4.gif" />
</div>
<!--cloud-->
<div id="home">
<h2>HOME</h2>
</div>
<!--home-->
</div>
<!--banner-->
</div>
<!--page-->
See this fiddle
Th background colour was not shown because, the element which contained the content was floated and thus the other elements were such that it doesnt even exist. thus,
Either change your css for #banner as follows
#banner {
float: left;
background-color: #78c8f0;
}
OR
change your css for #cloud as follows
#cloud {
/* float: left; */
padding: 0px;
margin: 0px;
}