Bootstrap full-width with 2 different backgrounds (and 2 columns) - html

It's a little bit hard to explain, that's why i also can't find the answer on Google.
I'm working with Bootstrap 3, and i need a full width background image. On top of that 2 transparent color backgrounds. I made a example image to make it all clear:
1+2: combined transparent color background
3+4: combined transparent color background
1+2+3+4: combined background image (lowest layer)
Does anyone know if this is possible and how? Thanks for your help!

Yes, using the techniques outlined in this question but extending it to the columns.
The Codepen Demo (below) shows the result better than the Stack Snippet which is included for reference.
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
overflow: hidden;
/* prevent scrollbar */
}
.container {
width:50%;
margin:auto;
margin-top: 1em;
position: relative;
overflow: visible;
}
.extra:before {
content: '';
display: block;
/* override bootstrap */
position: absolute;
top: 0;
left: 50%;
width: 100vw;
height: 100%;
transform: translate(-50%, 0);
}
[class*="col"] {
border: 2px solid grey;
min-height: 120px;
position: relative;
}
.left:before {
content: '';
position: absolute;
height: 100%;
width: 100vw;
top: 0;
right: 0;
background: rgba(255, 0, 0, 0.5)
}
.right:before {
content: '';
position: absolute;
height: 100%;
width: 100vw;
top: 0;
left: 0;
background: rgba(0, 0, 255, 0.25);
}
<div class="container extra">
<div class="row">
<div class="col-sm-4 left"></div>
<div class="col-sm-8 right"></div>
</div>
</div>
Codepen Demo

I think i figured it out.. Thanks to Paulie_D
Very simple example:
HTML:
<div class="fullwidth">
<div class="cell red20">xxx</div>
<div class="container cell">
<div class="row">
<div class="col-sm-4 red20">xx</div>
<div class="col-sm-8 red50">xx</div>
</div>
</div>
<div class="cell red50">xxx</div>
</div>
CSS:
.fullwidth {
background: url('http://www.ustudy.eu/nl/wp-content/uploads/2013/10/Test-taking-from-Flickr.jpg');
display:table;
width:100%;
}
.cell{
display:table-cell;
vertical-align:top;
}
.red20{
background-color:rgba(255,0,0,0.2);
}
.red50{
background-color:rgba(255,0,0,0.5);
}
Link to jsfiddle: https://jsfiddle.net/DTcHh/14045/

Related

Is it possible to create Multiple CSS3 using Transform or gradient Background?

I want to achieve this kind of Layout using Css Transform or gradient Background?(see image below). Right now im stuck with it using conic-gradient, i dont know how to put a gradient background on it.
see snippet below. run the code snippet as fullpage.
Thanks Guys.
//gol-bg
.my-bg-image {
background: url("https://via.placeholder.com/728x90.png?text=Background-image+Backgground-image+Background-image") 0 0 / cover no-repeat;
}
.gol-bg {
display: block;
height: 200px;
width: 700px;
position: relative;
background: conic-gradient(
transparent 136deg, transparent 0 140deg, yellow 140deg);
.my-content {
position: relative;
z-index: 1;
}
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.5.0/css/bootstrap.min.css" rel="stylesheet"/>
<div class="bg-dark my-bg-image">
<div class="row no-gutters">
<div class="col-6">
<div class="gol-bg">
<div class="my-content">content</div>
</div>
</div>
</div>
</div>
I'm not sure if i understood your question correctly but
Yes, you can use multiple transforms
(Also, take a look at this:
https://bennettfeely.com/clippy/)
Here's an example:
div {
height: 100px;
width: 100px;
background: #000;
color: #fff;
margin: 5em auto; /* Just to center it a bit */
/* Transform part */
transform: scale(2) rotate(90deg);
}
<div>Hello World</div>
this may not be the answer you are looking for but you can do this too. CSS is capable of making all sorts of shapes.
.my-bg-image {
background: url("https://via.placeholder.com/728x90.png?text=Background-image+Backgground-image+Background-image") 0 0 / cover no-repeat;
}
.gol-bg {
display: block;
position: relative;
width: 250px;
height: 0px;
border-left: 50px solid red;
border-right: 50px solid red;
border-bottom: 100px solid red;
border-top: 100px solid red;
position: relative;
}
.gol-bg:after {
content: '';
position: absolute;
background: transparent linear-gradient(91deg, #02b3bc 0, #171c8f 100%) 0 0 no-repeat padding-box;
width: 0;
height: 0;
border-left: 250px solid transparent;
border-right: 100px solid transparent;
border-bottom: 100px solid red;
position: absolute;
content: "";
top: 0px;
left: -50px;
}
.gol-bg .my-content {
position: relative;
z-index: 1;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.5.0/css/bootstrap.min.css" rel="stylesheet"/>
<div class="bg-dark my-bg-image">
<div class="row no-gutters">
<div class="col-6">
<div class="gol-bg">
<div class="my-content">content</div>
</div>
</div>
</div>
</div>

Bootstrap 4 stretch background of column to fill width of screen without container-fluid and keep alignment with grid [duplicate]

It's a little bit hard to explain, that's why i also can't find the answer on Google.
I'm working with Bootstrap 3, and i need a full width background image. On top of that 2 transparent color backgrounds. I made a example image to make it all clear:
1+2: combined transparent color background
3+4: combined transparent color background
1+2+3+4: combined background image (lowest layer)
Does anyone know if this is possible and how? Thanks for your help!
Yes, using the techniques outlined in this question but extending it to the columns.
The Codepen Demo (below) shows the result better than the Stack Snippet which is included for reference.
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
overflow: hidden;
/* prevent scrollbar */
}
.container {
width:50%;
margin:auto;
margin-top: 1em;
position: relative;
overflow: visible;
}
.extra:before {
content: '';
display: block;
/* override bootstrap */
position: absolute;
top: 0;
left: 50%;
width: 100vw;
height: 100%;
transform: translate(-50%, 0);
}
[class*="col"] {
border: 2px solid grey;
min-height: 120px;
position: relative;
}
.left:before {
content: '';
position: absolute;
height: 100%;
width: 100vw;
top: 0;
right: 0;
background: rgba(255, 0, 0, 0.5)
}
.right:before {
content: '';
position: absolute;
height: 100%;
width: 100vw;
top: 0;
left: 0;
background: rgba(0, 0, 255, 0.25);
}
<div class="container extra">
<div class="row">
<div class="col-sm-4 left"></div>
<div class="col-sm-8 right"></div>
</div>
</div>
Codepen Demo
I think i figured it out.. Thanks to Paulie_D
Very simple example:
HTML:
<div class="fullwidth">
<div class="cell red20">xxx</div>
<div class="container cell">
<div class="row">
<div class="col-sm-4 red20">xx</div>
<div class="col-sm-8 red50">xx</div>
</div>
</div>
<div class="cell red50">xxx</div>
</div>
CSS:
.fullwidth {
background: url('http://www.ustudy.eu/nl/wp-content/uploads/2013/10/Test-taking-from-Flickr.jpg');
display:table;
width:100%;
}
.cell{
display:table-cell;
vertical-align:top;
}
.red20{
background-color:rgba(255,0,0,0.2);
}
.red50{
background-color:rgba(255,0,0,0.5);
}
Link to jsfiddle: https://jsfiddle.net/DTcHh/14045/

Positioning points along a line

I'm trying to build the following component with CSS, but I can't get the first and last point to sit flush against the ends of the line.
It must be able to support an arbitrary number of points (between 1 and 4) and I can't rely on flexbox being there either.
I have a React component that's generating HTML that looks like this:
<div class="row">
<div class="col first" style="width:33%">
<div class="marker complete"></div>
<label>Feedback</label>
</div>
<div class="col" style="width:33%">
<div class="marker partial"></div>
<label>Observation</label>
</div>
<div class="col last" style="width:33%">
<div class="marker review"></div>
<label>Documentation</label>
</div>
</div>
The JavaScript calculates the column sizes before rendering and in my codepen implementation, I'm just centering all the content in each column.
I can sort of hack a solution by using the first and last classes to relatively position the end items, but invariably when the screen size changes, I start to get the edges of the line poking out from behind the points.
Does anyone know of a more sensible layout to start building this with?
My idea would be to set row as display: table-row, and then use a pseudo element to generate the horizontal bar. However, you run into the issue that you cannot know with CSS and HTML alone what the position of the first and last circle is relative to the size of the container. Therefore, it is not possible to use a full width item.
Another approach is using the labels as root items for the pseudo elements. They are always the full width of the column, so they give a nice indication what needs to be used.
The following proposed solution should work with IE9. The only special thing that is used is calc and after. (Instead of calc you can also use a transform: translate if you want.)
The basic idea is to use a table row, which would automatically scale nicely, and then use the labels as roots on which you can build the progress bar.
label:after {
content: "";
height: .5em;
background: #e2e2e2;
width: 100%;
position: absolute;
top: calc((100% - 1.5em) / 2); /* -1 to compensate text, -.5 for height bar */
left: 0;
z-index: -1;
}
.first label:after, .last label:after {
width: 50%;
}
.first label:after {
left: auto;
right: 0;
}
.single label:after {content: none;}
Here ya go. I assume this is what you are looking for.
<div class="row">
<div class="col" style="width:33%">
<div class="marker marker1 complete"></div>
<label>Feedback</label>
</div>
<div class="col2" style="width:33%">
<div class="marker marker2 partial"></div>
<label>Observation</label>
</div>
<div class="col3" style="width:33%">
<div class="marker marker3 review"></div>
<label>Documentation</label>
</div>
</div>
https://jsfiddle.net/norcaljohnny/e6nm2rbv/
*if JS was/is allowed I can put some conditions in it based on number and word length and adjust marker indentions.
Basically I used display blocks, margins and secondary marker classes for each block.
.row {
display: table;
margin: 0 auto;
position: relative;
width: 100%;
}
.col {
display: table-cell;
width: 33%;
text-align: center;
}
.marker {
width: 30px;
height: 30px;
background-color: lightgray;
border-radius: 30px;
margin: 0 auto;
}
.complete {
background-color: blue;
}
.partial {
background-color: blue;
box-sizing: border-box;
border: 8px solid lightgray;
}
.review {
background-color: lightblue;
}
.col:not(:last-child) > .marker:after {
content: '';
display: inline-block;
width: 67%;
height: 0;
border: 3px solid lightgray;
position: absolute;
left: 16.5%;
top: 12.5px;
z-index: -10;
}
/* ------------------------------------------- */
.wrapper {
display: flex;
align-items: center;
justify-content: center;
padding: 0 100px;
}
.point {
height: 30px;
background-color: lightgray;
border-radius: 30px;
flex: 0 0 30px;
position: relative;
}
.line {
height: 0;
border: 3px solid lightgray;
flex: 1 0;
}
.blue {
background-color: blue;
}
.lightblue {
background-color: lightblue;
}
.border {
background-color: lightgray;
background-image: radial-gradient(at center center, blue 0, blue 8px, transparent 8px, transparent 100%);
}
.point label {
position: absolute;
left: -50%;
top: 100%;
text-align: center;
}
<h1>Non flex</h1>
<div class="row">
<div class="col first">
<div class="marker complete"></div>
<label>Feedback</label>
</div>
<div class="col">
<div class="marker partial"></div>
<label>Observation</label>
</div>
<div class="col last">
<div class="marker review"></div>
<label>Documentation</label>
</div>
</div>
<h1>Flex</h1>
<div class="wrapper">
<div class="point blue">
<label>Feedback</label>
</div>
<div class="line"></div>
<div class="point blue border">
<label>Observation</label>
</div>
<div class="line"></div>
<div class="point lightblue">
<label>Documentation</label>
</div>
</div>

Bootstrap design container-fluid with differens color

I would like to achieve the following:
Have a fluid container with one background color on each side - but the separator should be two cols in the inside container.
I tried to describe it in this picture. Is this even possible?
use css positions and after/before see the link below:
Codepen
.container {
background: #ddd;
height: 250px;
}
.extra1 {
height: 250px;
background: #fff;
position: relative;
z-index: 999;
}
.extra2 {
height: 250px;
background: #000;
}
.extra1:before {
content: '';
background: yellow;
position: absolute;
width: 300%;
top: 0px;
height: 100%;
left: -200%;
}
.extra2:before {
content: '';
background: green;
position: absolute;
width: 300%;
top: 0px;
height: 100%;
right: -200%;
}
.your-things {
position: absolute;
left: 0;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" />
<div class="container">
<div class="row">
<div class="col-md-4 extra1">
<div class="your-things">
<p>.col-md-4</p>
</div>
</div>
<div class="col-md-8 extra2">
<div class="your-things">
<p>.col-md-8</p>
</div>
</div>
</div>
</div>
This can be done using psuedo element before and after on .container-fluid class or give any other class name.
Here is a code pen demo:
`http://codepen.io/duptitung/pen/adNOpV`
ya, you can give background image of the specific color and place it on that specific region
css
.container-fluid{
background:url( //image link// );
background-position: // arrange image // ;
background-size: auto 100%;
}

how to format links so that they are 25% of the viewport in all for corners?

I have successfully set up four divs so that they are 25% of the viewport, in each corner. Now I want to make them clickable links, so that I can apply background images that change upon hover.
Here's what I have:
html:
<div id="intro">
<div class="box topleft">
<h4 class="blockhead">link1</h4>
</div>
<div class="box topright">
<h4 class="blockhead">link2</h4>
</div>
<div class="box bottomleft">
<h4 class="blockhead">link3</h4>
</div>
<div class="box bottomright">
<h4 class="blockhead">link4</h4>
</div>
</div>
css:
#intro {
position: absolute;
width: 100%;
height: 100%;
}
.box {
position: inherit;
width: 50%;
height: 50%;
}
.box a:active,
.box a:link {
padding: 0;
background: none;
width: 100%;
height: 100%;
}
.box h4.blockhead {
position: absolute;
color: #ffffff;
padding: 5%;
}
.box.topleft h4.blockhead,
.box.topright h4.blockhead { bottom: 0 }
.box.topleft h4.blockhead,
.box.bottomleft h4.blockhead { right: 0 }
.box.topleft {
background: #bad80a;
top: 0;
left: 0;
}
.box.topright {
background: #0083d6;
top: 0;
right: 0;
}
.box.bottomleft {
background: #003f87;
bottom: 0;
left: 0;
}
.box.bottomright {
background: #ffc61e;
bottom: 0;
right: 0;
}
It's imperative that the text in the divs remain aligned as they are. ANY help in the right direction greatly appreciated.
And here it is on jsfiddle: http://jsfiddle.net/blackessej/j47Ye/3/
.box a:link {
/* rest of code */
display: block;
}
http://jsfiddle.net/j47Ye/1/
What you need to use is display:inline-block;. inline-block works like the block attribute, but it keeps everything on the same line. Using block in this case may work, as shown by Miljan, but it is not proper. So I would just add something like
.box a {
display:inline-block;
}
Then you should be good to go
JSFiddle