Banner image not shown in angular page - css

I am still learning about angular so I might not have the best design, but anyways I get confused not being so sure where my css should be. I have src/index.html, styles.css and src/app/app.component.html, app.component.html. I am trying to customize home.component.html, no home.component.css has been implemented. On .parallax-container I am trying to show an image, but not showing as a background image.
src/styles.css
div.sm-jumbotron {
padding: 2rem;
background-color: #38547b;
color: #ffffff;
}
button.btn-submit {
background-color: #38547b;
color: #ffffff;
width: 100%;
}
button.btn-submit:focus, button.btn-submit:hover {
background-color: #38547b;
}
input.ng-invalid.ng-dirty {
border-bottom-color: #e91e63 !important;
box-shadow: 0 1px 0 0 #e91e63 !important;
}
nav ul a,
nav .brand-logo {
color: #444;
}
p {
line-height: 2rem;
}
.sidenav-trigger {
color: #26a69a;
}
.parallax-container {
min-height: 380px;
line-height: 0;
height: auto;
color: rgba(0, 0, 0, 0.9);
}
.parallax-container .section {
width: 100%;
}
#media only screen and (max-width : 992px) {
.parallax-container .section {
position: absolute;
top: 40%;
}
#index-banner .section {
top: 10%;
}
}
#media only screen and (max-width : 600px) {
#index-banner .section {
top: 0;
}
}
.icon-block {
padding: 0 15px;
}
.icon-block .material-icons {
font-size: inherit;
}
footer.page-footer {
margin: 0;
}
app.component.html
<div class="container" [style.margin-top.px]="navbarTopMargin">
<app-nav (navHeight)="onNavHeight($event)"></app-nav>
</div>
<div id="container">
<div class="my-custom-container" [style.margin-top.px]="routerOutput">
<router-outlet></router-outlet>
</div>
</div>
home.component.html
<div id="index-banner" class="parallax-container">
<div class="section no-pad-bot">
<div class="container">
<br><br>
<h1 class="header center teal-text text-lighten-2">Join Us</h1>
<div class="row center">
<h3 class="header col s12 light">We sell and deliver products to customers that will improve health.</h3>
</div>
<div class="row center">
Get Started
</div>
</div>
</div>
<!--Show this image-->
<div class="parallax"><img src="https://mdbootstrap.com/img/Photos/Others/architecture.jpg" alt=""></div>
</div>
<div class="container">
<div class="section">
<div class="row">
<div class="col s12 m4">
<div class="icon-block">
<h2 class="center brown-text"><i class="material-icons">flash_on</i></h2>
<h3 class="center">Fast delivery</h3>
<p class="light">
We are the fastest delivery service in America.
</p>
</div>
</div>
<div class="col s12 m4">
<div class="icon-block">
<h2 class="center brown-text"><i class="material-icons">group</i></h2>
<h3 class="center">Top quality</h3>
<p class="light">
We make sure the quality is great.
</p>
</div>
</div>
<div class="col s12 m4">
<div class="icon-block">
<h2 class="center brown-text"><i class="material-icons">location_city</i></h2>
<h3 class="center">Trusted company</h3>
<p class="light">
This company has received 98% satisfaction.
</p>
</div>
</div>
</div>

Please try this css in your style.css:
.parallax-container .parallax{
position: static;
}
.parallax-container .parallax img{
position: static;
transform: none;
display: block;
max-width: 100%;
}

Related

buttons problems when shrink the page

I'm trying to do this nav but when I shrink the page the buttons look terrible.
In desktop mode it works, and only when I shrink the page does it give me problems. The buttons become huge because if there is a long writing it goes to the head:
<section class="main_buttons">
<div class="container d-none d-sm-none d-md-block">
<div class="row">
<div class="col-xl-3 col-lg-3 col-md-3">
<div class="button">
<div class="nav_btn btn btn-primary">
<div class="contenitore">
three long words
<img src="assets/img/.." alt="">
</div>
</div>
</div>
</div>
<div class="col-xl-3 col-lg-3 col-md-3">
<div class="button">
<div class="nav_btn btn btn-primary">
<div class="contenitore">
testtest
<img src="assets/img/.." alt="">
</div>
</div>
</div>
</div>
<div class="col-xl-3 col-lg-3 col-md-3">
<div class="button">
<div class="nav_btn btn btn-primary">
<div class="contenitore">
testtesttest
<img src="assets/img/.." alt="">
</div>
</div>
</div>
</div>
<div class="col-xl-3 col-lg-3 col-md-3">
<div class="button">
<div class="nav_btn btn btn-primary">
<div class="contenitore">
test test test test
<img src="assets/img/..." alt="">
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-xl-3 col-lg-3 col-md-3">
<div class="button">
<div class="nav_btn btn btn-primary">
<div class="contenitore">
testtest test testtest
<img src="assets/img/.." alt="">
</div>
</div>
</div>
</div>
<div class="col-xl-3 col-lg-3 col-md-3">
<div
class="button">
<div class="nav_btn btn btn-primary sos-button">
<div class="contenitore">
test test test
</div>
</div>
</div>
</div>
<div class="col-xl-3 col-lg-3 col-md-3">
<div
class="button">
<div class="nav_btn btn btn-primary sos-button">
<div class="contenitore">
testtest test
</div>
</div>
</div>
</div>
</div>
</div>
HERE'S THE STYLE
.nav_btn {
text-align: left !important;
margin: 2px 0;
width: 100%;
background-color: white !important;
border:2px solid #0062CC;
padding-left: 10px;
font-size: 16px;
&:hover {
background-color: #0062CC !important;
}
&:hover a {
color:white !important;
}
.contenitore {
width:100%;
display: flex;
justify-content: space-between;
i {
line-height:20px;
}
img {
width: 20px;
}
a {
text-decoration: none;
color:#0062CC;
font-weight: bold;
}
}
}
}
.button .sos-button {
border: 2px solid #ff4081;
&:hover {
background-color: #ff4081 !important;
}
&:hover a {
color: white;
}
a {
color: #ff4081 !important;
}
}
Using width with border can sometimes make elements larger than you expect.
You can controlled the button width, out of the .nav_btn. I tried a lot of ways and i think these are the best solution for this situation.
.button {
width: 200px; //You can try like that way
}
.nav_btn {
text-align: left ;
margin: 2px;
background-color: white ;
border:2px solid #0062CC;
padding-left: 10px;
font-size: 16px;
}
.nav_btn:hover {
background-color: #0062CC ;
}
.nav_btn a:hover {
color:white ;
}
.contenitore {
display: flex;
justify-content: space-between;
}
i {
line-height:20px;
}
img {
width: 20px;
}
a {
text-decoration: none;
color:#0062CC;
font-weight: bold;
}
.button .sos-button {
border: 2px solid #ff4081;
}
.button .sos-button:hover {
background-color: #ff4081;
}
.button .sos-button:hover a {
color: white;
}
a {
color: #ff4081;
}
or try this one.
.nav_btn {
text-align: left ;
width: 200; //or you can try like this one
margin: 2px;
background-color: white ;
border:2px solid #0062CC;
padding-left: 10px;
font-size: 16px;
}
.nav_btn:hover {
background-color: #0062CC ;
}
.nav_btn a:hover {
color:white ;
}
.contenitore {
display: flex;
justify-content: space-between;
}
i {
line-height:20px;
}
img {
width: 20px;
}
a {
text-decoration: none;
color:#0062CC;
font-weight: bold;
}
.button .sos-button {
border: 2px solid #ff4081;
}
.button .sos-button:hover {
background-color: #ff4081;
}
.button .sos-button:hover a {
color: white;
}
a {
color: #ff4081;
}

How to make div expand with content using flex?

I have this HTML and CSS:
.container {
width: 100%;
}
.group {
display: flex;
justify-content: space-between;
min-width: 214px;
background: #eee;
}
.abbr {
/* some styling */
}
.name {
/* some styling */
}
<div class="container">
<div class="group">
<div class="abbr">
<p>MS</p>
</div>
<div>
<p class="name">Mark Smith</p>
</div>
</div>
</div>
Now, if I use just min-width, the whole div stretches as the entire width of the container. If I just use width, it won't expand if the name is longer than Mark Smith (rather it will go to the next line).
This is what I wanted to achieve:
How do I achieve this in flexbox?
What you're looking for is to apply width: fit-content to .group.
Then you can adjust the offset between the abbreviation and name with min-width on the .abbr.
This can be seen in the following:
.group {
display: flex;
width: fit-content;
background: #eee;
margin: 10px 0;
}
.group > div {
margin: 0 10px;
}
.abbr {
min-width: 50px;
}
<div class="container">
<div class="group">
<div class="abbr">
<p>MS</p>
</div>
<div>
<p class="name">Mark Smith</p>
</div>
</div>
<div class="group">
<div class="abbr">
<p>MS</p>
</div>
<div>
<p class="name">A Really Really Long Name</p>
</div>
</div>
</div>
I use inline-block on .container so that it won't take up the whole line.
.container {
display: inline-block;
}
.group {
display: flex;
background: #eee;
}
.abbr {
padding: 0 7px;
}
.name {
padding: 0 7px;
}
<div class="container">
<div class="group">
<div class="abbr">
<p>MS</p>
</div>
<div>
<p class="name">Mark Smith</p>
</div>
</div>
</div><br/><br/>
<div class="container">
<div class="group">
<div class="abbr">
<p>MR</p>
</div>
<div>
<p class="name">Loooooooooooooooong Name</p>
</div>
</div>
</div>
Another solution is to use a third element that consume all the remaining space and set the background color on the text content only:
.container {
margin: 0 0 5px 0;
}
.group {
display: flex;
}
.abbr {
padding: 0 7px;
background: #eee;
}
.name {
padding: 0 7px;
background: #eee;
flex: 0 0 auto;
}
.blank-space{
flex: 1 1 auto;
}
<div class="container">
<div class="group">
<div class="abbr">
<p>MS</p>
</div>
<div class="name">
<p>Mark Smith</p>
</div>
<div class="blank-space"></div>
</div>
</div>
<div class="container">
<div class="group">
<div class="abbr">
<p>MR</p>
</div>
<div class="name">
<p>Loooooooooooooooong Name</p>
</div>
<div class="blank-space"></div>
</div>
</div>

How to fit images set like facebook in bootstrap css & angular 7

I want to fit images set like facebook photo albums showing in newsfeed.
When I'm trying this it will show with huge spaces.
here is my code
html code
<div class="pCollection">
<div class="row pCollection-header">
<div *ngFor="let photo of getPhotos(); let i=index" class="col-md-6">
<div *ngIf="photos.length > 4">
<div *ngIf="i != 3">
<div class="card">
<div class="card-img-wrapper">
<img class="card-img-top" (click)="open(i)" src="{{photo.src}}" alt="">
<div class="overlay">
<p *ngIf="i == 3" class="restImages"> + {{photos.length - 4}}</p>
</div>
</div>
</div>
</div>
<div *ngIf="i == 3">
<div class="card">
<div class="card-img-wrapper">
<img class="card-img-top" (click)="open(i)" src="{{photo.src}}" alt="">
<div class="overlay">
<p class="restImages"> + {{photos.length - 4}}</p>
</div>
</div>
</div>
</div>
</div>
<div *ngIf="photos.length < 5">
<div class="card">
<div class="card-img-wrapper">
<img class="card-img-top" (click)="open(i)" src="{{photo.src}}" alt="">
</div>
</div>
</div>
</div>
</div></div>
this is my css code
.pCollection-header .col-md-6 {
padding-left: 0;
padding-right:0;
}
.pCollection {
overflow: hidden;
}
.card{
cursor: pointer;
}
.card-img-wrapper {
position: relative;
/* background: rgba(0, 0, 0, 0.7); */
}
.card-img-wrapper img{
background: rgba(0, 0, 0, 0.7);
}
.overlay{
position: absolute;
top: 35%;
left: 36%;
z-index: 1000;
}
.restImages {
color: #fff;
font-size: 35px;
}
#media (min-width: 576px) {
.restImages {
font-size: 24px;
}
}
#media (min-width: 768px) {
.restImages {
font-size: 24px;
}
}
#media (min-width: 992px) {
.restImages {
font-size: 35px;
}
}
#media (min-width: 1200px) {
.restImages {
font-size: 35px;
}
}
this is the screenshot for this code
this is the screenshot for what I'm expecting
please anyone know how to do this,please help me.I wasted few days for this issue.
You can use jQuery plugin for this if you want. You can see the demo it's exactly what you want.
Try this CSS for the stackblitz which you created...
p {
font-family: Lato;
}
.paddingReset>div{
padding:0;
}
.img-responsive-custom{
max-width: 100%;
display:block;
height: auto;
}
.left-set>img{
border-right:2px;
border-bottom: 0px;
border-left:2px;
border-style: solid;
border-color: #fff;
}
.right-set>img{
border-top:1px;
border-right:2px;
border-left:2px;
border-style: solid;
border-color: #fff;
}
.column9Custom{width:75%;}
.column3Custom{width:25%;}

How can I alternate the float of my content?

I want to create a layout for an itemised list of content like below:
Each item is a container that has an image and block of text.
I have attempted to use nth-child and set different css float values based on if it is an odd or even child, but you can't set child properties using the nth-child selector.
HTML:
<div class="flex-container">
<div class="media-container ">
<img src="img/image.png">
</div>
<div class="text-container">
<div class="titles">
<h2>Title #1</h2>
</div>
<p>lots of words</p>
</div>
</div>
<div class="flex-container">
<div class="media-container ">
<img src="img/image.png">
</div>
<div class="text-container">
<div class="titles">
<h2>Title #1</h2>
</div>
<p>lots of words</p>
</div>
</div>
<div class="flex-container">
<div class="media-container ">
<img src="img/image.png">
</div>
<div class="text-container">
<div class="titles">
<h2>Title #1</h2>
</div>
<p>lots of words</p>
</div>
</div>
CSS:
.flex-container {
width: auto;
margin: 10px auto;
padding: 0 15px;
display: inline-flex;
}
.flex-container:nth-child(odd) {
.media-container {
float: left;
}
.text-container {
float: right;
}
}
.flex-container:nth-child(even) {
.media-container {
float: right;
}
.text-container {
float: left;
}
}
.media-container {
position: relative;
display: inline-block;
}
.media-container img {
width: 100%;
height: auto;
}
.text-container {
width: 30%;
margin: 0 10px;
align-self: center;
position: relative;
display: inline-block;
}
What is the easiest/neatest solution for creating this layout using CSS?
Something like this:
Use the nth-child on your "row" flex-containers and alternate the flex-direction.
.flex-container {
padding: 0 15px;
display: flex;
width: 80%;
border: 1px solid grey;
margin: 1em auto;
}
.flex-container:nth-child(odd) {
flex-direction: row;
}
.flex-container:nth-child(even) {
flex-direction: row-reverse;
}
.media-container img {
width: 100%;
height: auto;
}
.text-container {
width: 30%;
margin: 0 10px;
}
<div class="flex-container">
<div class="media-container ">
<img src="http://www.fillmurray.com/300/200">
</div>
<div class="text-container">
<div class="titles">
<h2>Title #1</h2>
</div>
<p>lots of words</p>
</div>
</div>
<div class="flex-container">
<div class="media-container ">
<img src="http://www.fillmurray.com/300/200">
</div>
<div class="text-container">
<div class="titles">
<h2>Title #1</h2>
</div>
<p>lots of words</p>
</div>
</div>
Take A Look At This:
.item {
width: 305px;
height: 70px;
background: black;
margin: 5px;
padding: 5px;
}
.item .title {
width: 200px;
height: 70px;
background: crimson;
}
.item .img {
width: 100px;
height: 70px;
background: #09f;
}
.item:nth-child(even) .img {
float: right;
}
.item:nth-child(even) .title {
float: left;
}
.item:nth-child(odd) .img {
float: left;
}
.item:nth-child(odd) .title {
float: right;
}
<div class='item'>
<div class='title'></div>
<div class='img'></div>
</div>
<div class='item'>
<div class='title'></div>
<div class='img'></div>
</div>
<div class='item'>
<div class='title'></div>
<div class='img'></div>
</div>
Is it necessary that it is display:inline-flex? If you change it to inline-block, I believe you'll get your intended display:
.flex-container {
display: inline-block;
...
}
https://jsfiddle.net/4rcdqy4f/
You can use the Javascript querySelectorAll() method. Then, loop through the list of your items and add the specific CSS property based on whether it is odd or even.

Resize image in ionic cards

I want display a set of images with a description below. I chose to use Ionic cards.
I got this result (the first image):
While I want to preserve the same layout I have now, and add a description.
Here is my code:
<ion-content ng-controller="cityController">
<div class="row">
<div class="col col-33">
<div class="list card">
<div class="item item-body">
<img class="full-image"src="img/images/opera.jpg"/>
This is a "Facebook" styled Card..
</div>
</div>
</div>
<div class="col col-33">
<img src="img/images/basilique.jpg"/>
</div>
<div class="col col-33">
<img src="img/images/hoteldeville.jpg"/>
</div>
</div>
.center {
text-align: center;
}
.col {
overflow: hidden;
}
.row {
overflow: hidden;
height: 180px;
}
.fullscreen {
width: 100%;
height: 100%;
}
How can I fix this?
UPDATE
You have to change your source little bit.
Example HTML:
<div class="row">
<div class="col col-33">
<img class="full-image" src="http://www.w3schools.com/css/img_fjords.jpg"/>
<div class="card-description">This is a "Facebook" styled Card..</div>
</div>
<div class="col col-33">
<img class="full-image" src="http://www.w3schools.com/css/img_forest.jpg"/>
<div class="card-description">This is a "Facebook" styled Card..</div>
</div>
<div class="col col-33">
<img class="full-image" src="http://www.w3schools.com/css/img_mountains.jpg"/>
<div class="card-description">This is a "Facebook" styled Card..</div>
</div>
</div>
Example CSS:
.col-33 {
width: 33%;
float:left;
}
.full-image {
width: 100%;
height: 100%;
}
.card-description {
text-align: center;
}
Live demo here
This is just an example how it can work.
UPDATE:
To have the images full sized, you need to put the description over it.
In that case this CSS is required.
.col-33 {
width: 33%;
float:left;
position: relative;
}
.full-image {
width: 100%;
height: 100%;
}
.card-description {
position: absolute;
bottom: 0;
left: 0;
right: 0;
text-align: center;
padding: 5px;
line-height: 1.5;
background-color: rgba(255, 255, 255, 0.6);
}

Resources