I'm working on a small site for a startup
the site works well on desktops, but I'm trying to make it more responsive
using the Bootstrap grid system, however I'm getting red grid lines
What am I doing wrong?
Screenshot
HTML and CSS code below
<section class="tds-banner">
<div class="overlay">
<div class="description">
<div class="container">
<div class="row">
<div class="col-xs-12 col-sm-12">
<h1>Fishing Club Studios</h1>
</div>
</div>
<div class="row">
<div class="col--xs-12 col-sm-12">
<h5>We Make food and We drinks</h5>
</div>
</div>
<div class="row">
<div class="col-6">
Food
</div>
<div class="col-6">
Drinks
</div>
</div>
</div>
</div>
</section>
<style>
<!--CSS-->
#media only screen and (min-device-width: 300px) {
.tds-banner .overlay{
position: absolute;
min-height: 100%;
min-width: 100%;
left: 0;
top: 0;
background-image:url('/static /talking_drumstudios_logo_360.png');
background-attachment: fixed;
background-size: contain;
background-position: center;
background-repeat: no-repeat;
}
.description {
font-size: 20px;
border: none
}
}
</style>
When you find this kind of issues with borders using frameworks to override, inspect the element and try properties like:
border: none;
box-shadow: none;
outline: none;
About your text issues, I don't have access to your code but you probably have:
Reduce the padding on the container or margin on the divs, that's
why you have all this white space on top and left.
Or I see that you're using position absolute in some cases, try using to the minimum otherwise you'll have more work trying to do the responsiveness.
From your screenshot, it seems like you have assigned border to row or column class, try this CSS code:
.row,col-*{
border-width:0px;
}
Related
Context:
I am trying to create 3 charts on 1 row (each has a minimum width) such that on window resize, the charts should also resize and may go to next row depending on the browser total width.
Problem:
Currently, I am missing something in the css because the chart is overflowing within the demo container below. The tooltip looks fine, but only half of the chart is seen in the container and both the axes are also hidden.
Has someone implemented something similar before? I want to understand how to load the charts in the div.
P.S. In the code below, highcharts-container is the inbuilt div which contains the charts. I am using the latest version of Highcharts and Angular 7.
My current html code -->
<div class="container-fluid">
<div class="row">
<div class="col-lg-4 col-md4 demo>
<div class="demo-container">
<highcharts-chart [Highcharts]="Highcharts" [options]="options1" [callbackFunction]="cb1">
</highcharts-chart>
</div>
</div>
<div class="col-lg-4 col-md4 demo>
<div class="demo-container">
<highcharts-chart [Highcharts]="Highcharts" [options]="options2" [callbackFunction]="cb2">
</highcharts-chart>
</div>
</div>
<div class="col-lg-4 col-md4 demo>
<div class="demo-container">
<highcharts-chart [Highcharts]="Highcharts" [options]="options3" [callbackFunction]="cb3">
</highcharts-chart>
</div>
</div>
</div>
</div>
My css code (The main part) -->
.container-fluid{
width:100%
}
.demo{
margin: 20px 0;
min-width: 448px;
}
.demo-container{
position: relative;
border: 1px solid transparent;
box-shadow: 0 0 20px #1793f5;
width: 100%;
height: 100%;
}
.highcharts-container{
height: 100% !important;
width: 100% !important;
display: inline-block;
vertical-align: middle;
}
You could try to include the following CSS as a part of demo-container or container-fluid... one of it should do the deal for you.
height: 100% !important;
width: 100% !important;
Update
one of the harder challenges i have encountered, but add this to the style.css
and you have your contents dynamic inside its container.
.highcharts-background, .highcharts-root, .highcharts-container {
max-height: 100%;
max-width: 100%;
}
is this what you are looking for?
This was made using images of the graphs in the links you posted. I also used flexboxes which seems to be what you are looking for.
https://css-tricks.com/snippets/css/a-guide-to-flexbox/
.container-fluid div {
width: auto;
border: 2px solid red;
min-width: 33%;
}
.container-fluid{
display: flex;
flex-wrap: wrap;
border: 2px solid blue;
justify-content: center;
}
<div class="container-fluid">
<div class="chartOne">
<img src="https://i.gyazo.com/161954d0841b7a398d5f0d63e1b2bcc4.png" alt="">
</div>
<div class="chartOne">
<img src="https://i.gyazo.com/161954d0841b7a398d5f0d63e1b2bcc4.png" alt="">
</div>
<div class="chartOne">
<img src="https://i.gyazo.com/161954d0841b7a398d5f0d63e1b2bcc4.png" alt="">
</div>
</div>
How can I center a div with 3 .profilebox elements on any screens? and make it responsive?
• Big screens: One row with my 3 elements
• laptop screens: Two rows (2 elements on the first row, 1 element below)
• Tablet and mobile: 3 rows with one element per row vertically align (centered)
You can check what I want here:
HTML:
<div class="container" style="max-width: 1300px;">
<div class="row">
<div class="centerDiv">
<div class="profilebox ">
<div class="profileInfo">
<h3 class="box-shadow">Errore Aethiopia dolorum amni</h3>
</div>
</div>
</div>
</div>
And I have 3 divs .profilebox rendering 3 boxes with my image + title.
CSS :
.centerDiv {
padding-bottom: 200px;
padding-top: 100px;
margin-right: 0 auto;
margin-left: 0 auto;
}
.profilebox {
width: 350;
height: 210;
cursor: pointer;
display: inline-table;
margin-bottom: 100px;
background-image: url("");
background-position: center center;
background-size: cover;
position: relative;
}
.profilebox .profileInfo {
bottom: 0;
height: 50px;
left: 0;
right: 0;
margin: 0 auto;
position: absolute;
width: 88%;
}
With this code, my box is well designed. My img and title are in the right place. The only thing now is to make it centered in any situation.
I am a beginner in web development, some things may not be meaningful in my code right now. thanks a lot for your help.
You can use CSS flexbox
.container{
display:flex;
flex-wrap: wrap;
justify-content: center;
}
.profile-box{
width:500px;
height:300px;
margin:20px;
border:2px solid #000;
}
.profile-box{
position: relative;
}
.profile-box p{
position: absolute;
top:50%;
left:50%;
transform:translate(-50%,-50%);
margin:0;
}
<div class="container">
<div class="profile-box">
<p>profile box</p>
</div>
<div class="profile-box">
<p>profile box</p>
</div>
<div class="profile-box">
<p>profile box</p>
</div>
</div>
If you would like to use bootstrap, refer the following -
You could simply use the classes col-xl-4 col-lg-6 col-md-6 col-sm-12 as follows -
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<div class="container">
<div class="row">
<div class="col-xl-4 col-lg-6 col-md-6 col-sm-12">
ProfileBox
</div>
<div class="col-xl-4 col-lg-6 col-md-6 col-sm-12">
ProfileBox
</div>
<div class="col-xl-4 col-lg-6 col-md-6 col-sm-12">
ProfileBox
</div>
</div>
</div>
You will finally get 3 elements on extra large screens, 2 on large & medium screens & 1 on small screens in each row.
To see it live with resizing, check it here.
Note: You don't need to worry about different browsers if you use bootstrap.
How to make image between two grid dives? That image would be 50% on one and 50% on another?
<div class="row">
<div class="col-lg-12">
</div>
</div>
<div class="sec-div">
<img class="img-fluid img-second "src="http://lorempixel.com/400/200/cats">
</div>
<div class="row">
<div class="col-lg-12 second">
</div>
</div>
I think you should use z-index to keep the img below - not sure if will be necessary, set the body { background-color: gray } and set the margin of the main div with a negative value. I think this will work.
Try this: (I'm assuming you're using Bootstrap)
HTML:
<div class="container-fluid" id="header"></div>
<div class="container second">
<div class="col-lg-12 ">
</div>
</div>
CSS:
#header {
padding: 2% 0% 5% 0%; /* you should control img height through here, as width will be viewport sized */
background: url('images/pool.jpg');
background-attachment: static;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
z-index: 0 /* try using this to set this div below the other */
}
.second {
margin: /* negative value */
z-index: /* bootstrap items have really high numbers, so I guess this won't be necessary */
}
See it working here! https://jsfiddle.net/hokumi/m7qoy7h3/
I can't figure out a consistent way to add a small image between rows
Let's say I have this html
<div class="row">
...
</div>
<div class="row">
...
</div>
Now I need to display a small image between them but without affecting the rows.
There is a brown row and a black row, and the image with stars between them. How can I do this in a consistent way?
I tried adding a div with the image to the end of the row div like that
<div class="row">
...
<div class="div-with-image" style="position:absolute; bottom: -10px;">
<img src="...">
</div>
</div>
This kind of works but not in a consistent way. I tried adding the div.div-with-image inside the columns div, but that's not good either as sometimes the row is with a fixed size and that messes it up.
Does anyone have any good ideas? I know like 2 ways how to do it, but none of them are consistent and not very well reusable.
EDIT:
I think I have an idea.
<div class="row outer">
<div class="cols">
<div class="row">
<div class="cols star-row">
...
</div>
</div>
</div>
</div>
<style>
.outer{
background-image: url('somethingnice.png');
}
.star-row{
background-image: url('star-row.png');
background-position: 50% 101%;
}
</style>
I'll try this and let you know how this works.
This is not between so much as over the top of. Basically it uses a pseudo element (:after) and creates an overlay of the image of stars that is matched to the space available. It keeps the HTML minimal and the CSS does all the heavy lifting so you can easily change or tweak for different screen sizes.
HTML:
<div class="row columns small-12 brown"></div>
<div class="row columns small-12 black"></div>
CSS:
.black {
background-color: black;
z-index:-1; /* make behind .brown:after */
}
.brown {
background-color: brown;
}
.black,
.brown {
height: 20px; /* half height of image */
}
.brown:after {
content: '';
width: 100%;
display: block;
height: 40px; /* brown + black */
background: url('star-row.png') 50% 5px fixed no-repeat; /* adjust to match your image dimensions */
z-index: 2;
}
JSFiddle example
Edit - Another approach
Alternatively you could use HTML coded stars then the positioning is easier and the rows can vary in height as long as they don't go past a minimum (the height of the stars), but you have to decide on your number of stars. Media Queries can sort out how many to show for various screen sizes, or what font size to use.
CSS:
.black {
background-color: black;
position: relative;
}
.brown {
background-color: brown;
z-index: -1;
}
.black, .brown{
min-height:30px;
}
.black:before {
content: '\2605\00a0\00a0\2605\00a0\00a0\2605\00a0\00a0\2605\00a0\00a0\2605\00a0\00a0\2605\00a0\00a0\2605\00a0\00a0\2605\00a0\00a0\2605\00a0\00a0\2605';
color: #fff;
text-align: center;
font-size: 36px;
width: 100%;
display: block;
height: 60px;
position: absolute;
top: -30px;
}
(Your) HTML:
<div class="row brown">
<div class="large-12 columns">
<p>[content]</p>
<p>[more content]</p>
</div>
</div>
<div class="row black">
<div class="large-12 columns">
<p>[content]</p>
<p>[etc]</p>
</div>
</div>
(where \2605 is a star and \00a0 is a non-breaking space)
Updated JSFiddle
I have a page in which I am using bootstrap for designing. Now I am using grids; I want to keep 8 columns for my image and 4 columns for the text. So i have following code:-
<div class="container-fluid">
<div class="row">
<div class="col-md-8">
<div class="bg"></div>
</div>
<div class="col-md-4">
hi how are you
</div>
</div>
</div>
Following is the css for class bg :
.bg {
background-image: url('../images/2.jpg');
background-repeat: no-repeat;
background-position: center center;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
height:690px;
}
Now everything works fine, but I am facing a small problem here where i am checking this in extra small screen, the picture occupies almost the entire screen and for text i have to scroll way to the bottom.
Is there any way to adjust image height(width works perfectly fine) for extra small screens so that image and text can be seen together without much scrolling?
Try using viewport-height in CSS3:
.bg {
height:100vh;
}
do like this.give div class name as img-responsive and set width and height as your need.and put your image inside it and set its width and height like this.
<div class="img-responsive" style="width: 300px;height: 300px;">
<img style="width: 100%;height: 100%" src="http://www.intrawallpaper.com/static/images/1250654-for-laptop-nature.jpg"/>
</div>
if you want text over picture, you can do this:
#media (max-width: 480px) {
.bg {
position: absolute;
left: 0;
width: 100%;
}
}
if you want half top is picture, half bottom is text, you can do this:
html
<div class="container-fluid">
<div class="row">
<div class="col-md-8">
<div class="wrap">
<div class="bg"></div>
</div>
</div>
<div class="col-md-4">
hi how are you
</div>
</div>
</div>
css
#media (max-width: 480px) {
.wrap {
position: relative;
padding-bottom: 50%;
}
.bg {
position: absolute;
left: 0;
width: 100%;
height: 100%;
}
}
hope it can help