Bootstrap - Cards not working properly - php

I am following the examole from the first example on this page https://mdbootstrap.com/components/cards/ (trying to get same output)
<!--Card-->
<div class="card">
<!--Card image-->
<img class="img-fluid" src="https://mdbootstrap.com/img/Photos/Horizontal/Nature/4-col/img%20%282%29.jpg" alt="Card image cap">
<!--Card content-->
<div class="card-body">
<!--Title-->
<h4 class="card-title">Card title</h4>
<!--Text-->
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
Button
</div>
</div>
<!--/.Card-->
However, all i get is this ? any suggestions

I have added a different bootstrap link, hope this matches with your requirement
Try this
.card-body{
padding: 2rem;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.2/css/bootstrap.min.css" integrity="sha384-y3tfxAZXuh4HwSYylfB+J125MxIs6mR5FOHamPBG064zB+AFeWH94NdvaCBm8qnd" crossorigin="anonymous">
<div class="container">
<!--Card-->
<div class="card">
<!--Card image-->
<img class="img-fluid" src="https://mdbootstrap.com/img/Photos/Horizontal/Nature/4-col/img%20%282%29.jpg" width="550rem" alt="Card image cap">
<!--Card content-->
<div class="card-body">
<!--Title-->
<h4 class="card-title">Card title</h4>
<!--Text-->
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
Button
</div>
</div>
<!--/.Card-->
</div>

First of all, it's not pure bootstrap, you need add reference to mdb.min.css (you can download it from here).
Second, you need to limit the width of the div. like 300 px as an example (you could change it to whatever you like):
.card{
width:300px;
}
I tried it and can see the card is same as the website.

You didn't set any width in your parent div. that's why div automatically shows full width. First you need to add width like below code or use col-md-*
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.3/css/bootstrap.min.css" integrity="sha384-Zug+QiDoJOrZ5t4lssLdxGhVrurbmBWopoEl+M6BdEfwnCJZtKxi1KgxUyJq13dy" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/mdbootstrap/4.4.3/css/mdb.min.css">
<!--Card-->
<div class="card" style="width: 23rem;">
<!--Card image-->
<img class="img-fluid" src="https://mdbootstrap.com/img/Photos/Horizontal/Nature/4-col/img%20%282%29.jpg" alt="Card image cap">
<!--Card content-->
<div class="card-body">
<!--Title-->
<h4 class="card-title">Card title</h4>
<!--Text-->
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
Button
</div>
</div>
<!--/.Card-->

You have to follow the tutorial from getting started they are other css class that comes after content. Eg container-fluid etc. Ensure you follow the tutorial from beginning and ensure your have the library link properly to your page or download it and try it locally. They are classes missing and card class is supposed to have the box-shadow property while container-fluid or content-fluid give the section the appropriate padding. Hope this help

Check the order of files including first of all jquery is required then bootstrap and after that mdb file should be include
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/mdbootstrap/4.4.3/js/mdb.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/mdbootstrap/4.4.3/css/mdb.min.css" rel="stylesheet"/>
<div class='container-fluid'>
<div class='section'>
<!--Card-->
<div class="card" style='width:23rem;'>
<!--Card image-->
<img class="img-fluid" src="https://mdbootstrap.com/img/Photos/Horizontal/Nature/4-col/img%20%282%29.jpg" alt="Card image cap">
<!--Card content-->
<div class="card-body">
<!--Title-->
<h4 class="card-title">Card title</h4>
<!--Text-->
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
Button
</div>
</div>
<!--/.Card-->
</div>
</div>

Related

HTML Bootstrap Coding | Cards

I am using a bootstrap to create cards for my site. I am trying to center the card contents of the grid image cards. I have tried applying class="center" into various parts and the items are still all aligned left. This is a snippet of one of the grids
<div class="col">
<div class="card">
<i class="fa fa-medkit fa-5x" aria-hidden="true" class="center"></i>
<div class="card-body">
<h5 class="card-title" >Allied Health</h5>
<p class="card-text" class="center"></p>
</div>
</div>
</div>
I added class="center" and even class="all contents aligned center" into different parts, but there was no change.
Add text-center to the card element.
Also, note that you can only have one class attribute per html element. To add multiple classes to a single element, you separate them with a space.
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.11.2/css/all.min.css" rel="stylesheet"/>
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap#4.0.0/dist/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<div class="col-6">
<div class="card text-center">
<i class="fa fa-medkit fa-5x" aria-hidden="true"></i>
<div class="card-body">
<h5 class="card-title">Allied Health</h5>
<p class="card-text">Some card text here...</p>
Go somewhere
</div>
</div>
</div>
add the attribute display: flexbox; to your div element.
You should add a justify-content-center class in it, to make it center the content in a flexbox way.
I can give you a useful link :center element in bootstrap

CSS/less from header file only works on the index page

Welcome to my first post. I've searched stackoverflow for an hour to find the awnser I need, but without succes.
I'm currently creating my own website to test php with processwire and bootstrap. I am quite new to programming in general, but I have only three weeks of experience with php/processwire. I'm using this because I got an internship where they use it and I would like to create my own project in my spare time to speed up the learning proces.
I'm using a separate header/footer file that I import in each template. I notice that my CSS that is imported in the header file only works on my home.php template and not on my other ones. The html/php from header works fine, it's just the css that isn't working.
My files:
site
assets
less
styles.less
templates
_includes
_head.php
_foot.php
home.php
basic-page.php
I tried:
Change to css instead of less
Changing css import with ../ instead of site/
Copying all content of home.php into basic-page.php to see if the
problem was in the template.
part of header:
<?php namespace ProcessWire; ?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<title><?php echo $page->title; ?></title>
<meta name="description" content="<?php echo $page->summary; ?>" />
<!-- MDB icon -->
<!-- <link rel="icon" href="img/mdb-favicon.ico" type="image/x-icon"> -->
<!-- Font Awesome -->
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.11.2/css/all.css">
<!-- Google Fonts Roboto -->
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap">
<!-- Google Fonts -->
<link href='//fonts.googleapis.com/css?family=Lusitana:400,700|Quattrocento:400,700' rel='stylesheet' type='text/css' />
<!-- Bootstrap core CSS -->
<link rel="stylesheet" type="text/css" href="site/assets/css/bootstrap/bootstrap.min.css" />
<!-- Material Design Bootstrap -->
<link rel="stylesheet" type="text/css" href="site/assets/css/bootstrap/mdb.min.css" />
<!-- Your custom styles (optional) -->
<link rel="stylesheet" type="text/css" href="site/assets/less/styles.less" />
</head>
<body>
part of footer
</footer>
<!--/.Footer-->
<!-- End your project here-->
<!-- jQuery -->
<script type="text/javascript" src="site/assets/js/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap#5.0.0-beta1/dist/js/bootstrap.bundle.min.js" integrity="sha384-ygbV9kiqUc6oa4msXn9868pTtWMgiQaeYH7/t7LECLbyPA2x65Kgf80OJFdroafW" crossorigin="anonymous"></script>
<!-- Bootstrap tooltips -->
<script type="text/javascript" src="site/assets/js/popper.min.js"></script>
<!-- Bootstrap core JavaScript -->
<script type="text/javascript" src="site/assets/js/bootstrap.min.js"></script>
<!-- MDB core JavaScript -->
<script type="text/javascript" src="site/assets/js/mdb.min.js"></script>
<!-- Your custom scripts (optional) -->
<script type="text/javascript" src="site/assets/js/main.js" ></script>
<!-- Import less file -->
<script type="text/javascript" src="/site/assets/js/less.js" ></script>
</body>
</html>
template home.php
<?php include('./_includes/_head.php'); // include header markup ?>
<main>
<!--Main layout-->
<div class="container">
<!--First row-->
<!--/.First row-->
<hr class="extra-margins">
<!--Second row-->
<div class="row">
<!--Test columnn-->
<div class="col-lg-4">
<!--Card-->
<div class="card wow fadeIn" data-wow-delay="0.2s">
<!--Card image-->
<img class="img-fluid" src="https://mdbootstrap.com/img/Photos/Horizontal/Architecture/4-col/img%20(3).jpg" alt="Card image cap">
<!--Card content-->
<div class="card-body">
<!--Title-->
<h4 class="card-title">This is title</h4>
<!--Text-->
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
Read more
</div>
</div>
<!--/.Card-->
</div>
<!--Test columnn-->
<!--First columnn-->
<div class="col-lg-4">
<!--Card-->
<div class="card wow fadeIn" data-wow-delay="0.2s">
<!--Card image-->
<img class="img-fluid" src="https://mdbootstrap.com/img/Photos/Horizontal/Architecture/4-col/img%20(3).jpg" alt="Card image cap">
<!--Card content-->
<div class="card-body">
<!--Title-->
<h4 class="card-title">This is title</h4>
<!--Text-->
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
Read more
</div>
</div>
<!--/.Card-->
</div>
<!--First columnn-->
<!--Second columnn-->
<div class="col-lg-4">
<!--Card-->
<div class="card wow fadeIn" data-wow-delay="0.4s">
<!--Card image-->
<img class="img-fluid" src="https://mdbootstrap.com/img/Photos/Horizontal/Architecture/4-col/img%20(1).jpg" alt="Card image cap">
<!--Card content-->
<div class="card-body">
<!--Title-->
<h4 class="card-title">This is title</h4>
<!--Text-->
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
Read more
</div>
</div>
<!--/.Card-->
</div>
<!--Second columnn-->
<!--Third columnn-->
<div class="col-lg-4">
<!--Card-->
<div class="card wow fadeIn" data-wow-delay="0.6s">
<!--Card image-->
<img class="img-fluid" src="https://mdbootstrap.com/img/Photos/Horizontal/Architecture/4-col/img%20(4).jpg" alt="Card image cap">
<!--Card content-->
<div class="card-body">
<!--Title-->
<h4 class="card-title">This is title</h4>
<!--Text-->
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
Read more
</div>
</div>
<!--/.Card-->
</div>
<!--Third columnn-->
</div>
<!--/.Second row-->
</div>
<!--/.Main layout-->
</main>
<?php include('./_includes/_foot.php'); // include footer markup ?>
template basic-page.php
<?php include('./_includes/_head.php'); // include header markup ?>
<main>
<!--Main layout-->
<div class="container">
<!--First row-->
<!--/.First row-->
<hr class="extra-margins">
<!--Second row-->
<div class="row">
<!--Test columnn-->
<div class="col-lg-4">
<!--Card-->
<div class="card wow fadeIn" data-wow-delay="0.2s">
<!--Card image-->
<img class="img-fluid" src="https://mdbootstrap.com/img/Photos/Horizontal/Architecture/4-col/img%20(3).jpg" alt="Card image cap">
<!--Card content-->
<div class="card-body">
<!--Title-->
<h4 class="card-title">This is title</h4>
<!--Text-->
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
Read more
</div>
</div>
<!--/.Card-->
</div>
<!--Test columnn-->
<!--First columnn-->
<div class="col-lg-4">
<!--Card-->
<div class="card wow fadeIn" data-wow-delay="0.2s">
<!--Card image-->
<img class="img-fluid" src="https://mdbootstrap.com/img/Photos/Horizontal/Architecture/4-col/img%20(3).jpg" alt="Card image cap">
<!--Card content-->
<div class="card-body">
<!--Title-->
<h4 class="card-title">This is title</h4>
<!--Text-->
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
Read more
</div>
</div>
<!--/.Card-->
</div>
<!--First columnn-->
<!--Second columnn-->
<div class="col-lg-4">
<!--Card-->
<div class="card wow fadeIn" data-wow-delay="0.4s">
<!--Card image-->
<img class="img-fluid" src="https://mdbootstrap.com/img/Photos/Horizontal/Architecture/4-col/img%20(1).jpg" alt="Card image cap">
<!--Card content-->
<div class="card-body">
<!--Title-->
<h4 class="card-title">This is title</h4>
<!--Text-->
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
Read more
</div>
</div>
<!--/.Card-->
</div>
<!--Second columnn-->
<!--Third columnn-->
<div class="col-lg-4">
<!--Card-->
<div class="card wow fadeIn" data-wow-delay="0.6s">
<!--Card image-->
<img class="img-fluid" src="https://mdbootstrap.com/img/Photos/Horizontal/Architecture/4-col/img%20(4).jpg" alt="Card image cap">
<!--Card content-->
<div class="card-body">
<!--Title-->
<h4 class="card-title">This is title</h4>
<!--Text-->
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
Read more
</div>
</div>
<!--/.Card-->
</div>
<!--Third columnn-->
</div>
<!--/.Second row-->
</div>
<!--/.Main layout-->
</main>
<?php include('./_includes/_foot.php'); // include footer markup ?>
Thank you for taking the time to read this. Any help is appreciated.
instead of this
<?php namespace ProcessWire; ?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<title><?php echo $page->title; ?></title>
<meta name="description" content="<?php echo $page->summary; ?>" />
<!-- MDB icon -->
<!-- <link rel="icon" href="img/mdb-favicon.ico" type="image/x-icon"> -->
<!-- Font Awesome -->
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.11.2/css/all.css">
<!-- Google Fonts Roboto -->
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap">
<!-- Google Fonts -->
<link href='//fonts.googleapis.com/css?family=Lusitana:400,700|Quattrocento:400,700' rel='stylesheet' type='text/css' />
<!-- Bootstrap core CSS -->
<link rel="stylesheet" type="text/css" href="site/assets/css/bootstrap/bootstrap.min.css" />
<!-- Material Design Bootstrap -->
<link rel="stylesheet" type="text/css" href="site/assets/css/bootstrap/mdb.min.css" />
<!-- Your custom styles (optional) -->
<link rel="stylesheet" type="text/css" href="site/assets/less/styles.less" />
</head>
<body>
change
<link rel="stylesheet" type="text/css" href="site/assets/less/styles.less" />
to
<?php include 'site/assets/less/styles.less'; ?>
that should work, and make sure you have
<?php include '/path/to/header.php'; ?>
in all of your files as well that works for me at least.

#include not working in Laravel5.4 [duplicate]

This question already has an answer here:
laravel blade #include not working
(1 answer)
Closed 5 years ago.
I am learning larval and following video on laracasts.com , In lecture 10 regarding layout and structure , I was trying the #include but it is not working .
Below are my files :
/views/layout.blade.php
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="">
<meta name="author" content="">
<link rel="icon" href="../../favicon.ico">
<title>Album example for Bootstrap</title>
<!-- Bootstrap core CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" integrity="sha384-rwoIResjU2yc3z8GV/NPeZWAv56rSmLldC3R/AZzGRnGxQQKnKkoFVhFQhNUwEyJ" crossorigin="anonymous">
<!-- Custom styles for this template -->
<link href=" {{ URL::asset('css/album.css') }}" rel="stylesheet" >
</head>
<body>
<div class="collapse bg-inverse" id="navbarHeader">
<div class="container">
<div class="row">
<div class="col-sm-8 py-4">
<h4 class="text-white">About</h4>
<p class="text-muted">Add some information about the album below, the author, or any other background context. Make it a few sentences long so folks can pick up some informative tidbits. Then, link them off to some social networking sites or contact information.</p>
</div>
<div class="col-sm-4 py-4">
<h4 class="text-white">Contact</h4>
<ul class="list-unstyled">
<li>Follow on Twitter</li>
<li>Like on Facebook</li>
<li>Email me</li>
</ul>
</div>
</div>
</div>
</div>
#inlcude('layouts.nav') <!-- This is not working -->
<section class="jumbotron text-center">
<div class="container">
<h1 class="jumbotron-heading">Album example</h1>
<p class="lead text-muted">Something short and leading about the collection below—its contents, the creator, etc. Make it short and sweet, but not too short so folks don't simply skip over it entirely.</p>
<p>
Main call to action
Secondary action
</p>
</div>
</section>
<div class="album text-muted">
<div class="container">
<div class="row">
<div class="card">
<img data-src="holder.js/100px280/thumb" alt="Card image cap">
<p class="card-text">This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
</div>
<div class="card">
<img data-src="holder.js/100px280/thumb" alt="Card image cap">
<p class="card-text">This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
</div>
<div class="card">
<img data-src="holder.js/100px280/thumb" alt="Card image cap">
<p class="card-text">This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
</div>
<div class="card">
<img data-src="holder.js/100px280/thumb" alt="Card image cap">
<p class="card-text">This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
</div>
<div class="card">
<img data-src="holder.js/100px280/thumb" alt="Card image cap">
<p class="card-text">This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
</div>
<div class="card">
<img data-src="holder.js/100px280/thumb" alt="Card image cap">
<p class="card-text">This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
</div>
<div class="card">
<img data-src="holder.js/100px280/thumb" alt="Card image cap">
<p class="card-text">This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
</div>
<div class="card">
<img data-src="holder.js/100px280/thumb" alt="Card image cap">
<p class="card-text">This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
</div>
<div class="card">
<img data-src="holder.js/100px280/thumb" alt="Card image cap">
<p class="card-text">This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
</div>
</div>
</div>
</div>
<footer class="text-muted">
<div class="container">
<p class="float-right">
Back to top
</p>
<p>Album example is © Bootstrap, but please download and customize it for yourself!</p>
<p>New to Bootstrap? Visit the homepage or read our getting started guide.</p>
</div>
</footer>
</body>
</html>
/views/layouts/nav.blade.php
<div class="navbar navbar-inverse bg-inverse">
<div class="container d-flex justify-content-between">
Album
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarHeader" aria-controls="navbarHeader" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
</div>
</div>
/views/posts/index.blade.php
#extends('layout')
Route is properly set:
Route::get('/','PostsController#index');
That's because that file is not in the app/views directory.
When you call #include('layouts.nav'), Blade automatically looks for any file with that name, inside the app/views directory.
Blade looks for the files in the paths array in /app/config/view.php , Adding one more resource path does the trick as following:
'paths' => [
resource_path('views'),
resource_path('/../views/layouts')
],

Integrate images to slideshow from database in specific sequence

Basically short information about this situation :
I have a slideshow like this
enter image description here
And front-end developer didn't find the easiest solution so here is the front-end code for background images :
<div class="item">
<div class="container-fluid">
<div class="row">
<div class="col-sm-6 less_spacing"> <img src="{{ url('/dd/img/img/ss/4.jpg') }}"> </div>
<div class="col-sm-6 less_spacing"> <img src="{{ url('/dd/img/img/ss/2.jpg') }}"> </div>
</div>
</div>
and here for the centre image :
<div class="item" style="background: url(/dd/img/dd/what/1.jpg) center; background-size:cover;">
<img src="{{ url('/dd/img/dd/what/1.jpg') }}" class="img-responsive hidden-lg hidden-sm hidden-md">
<span class="sml-logo"><img src="{{ url('/dd/img/sml-logo.png') }}" alt=""></span>
<div class="caption left_panel">
<div class="inner">
<p>... The key of the door that will open you to the world of gastronomy and history of modern Baltic cuisine, blending international tendencies and interesting selections of wine.</p>
</div>
</div>
</div>
How you can understand here there is 4 images in this example : the last is 4th.
The centre image is with ID : 1;
I can't make this just based on the ID's from the database because if user will delete some results then +1 -1 will not work for previous and the next image.
Summed up : Basically all I want in this situation is when user clicks on next image the background (left) image changes to the previous centre image and the background(right) side image changes to the next image (3rd) and so on...

Bootstrap 3 class="media-body" causes image to not be shown

I have the following code:
<div class="container-fluid>
{files}
<div class="media">
<div class="media-left">
<img src="<?php echo base_url('files/{filename}'); ?>" alt="afbeelding" class="media-object" style="width:200px">
</div>
<div class="media-body">
<h4 class="media-heading">{title}</h4>
<p>{text}</p>
</div>
</div>
<br>
{/files}
</div>
The current result is just the title and text being shown, without the image. When I remove the whole div with class "media-body", the image shows. I think my code is structured right, I followed the w3-schools example. How can I get both the image and text to show up in the bootstrap media format?
Missing "
Change from
<div class="container-fluid>
to
<div class="container-fluid">

Categories