How to remove unwanted break in bootstrap panel - php

I have panel where I'm displaying some basic informations about user. I want to display graph in the center of this panel.
I have problems with one unwanted space which I want to remove but I don't know how to do it.
Please look at image:
Code for this panel:
<div class="row">
<div class="panel panel-default">
<div class="panel-heading">Detail zákazníka </div>
<div class="panel-body">
<div class="form-group">
<label>ID zákazníka:</label>
<p><?php echo !empty($zakaznici['ID_zakaznici'])?$zakaznici['ID_zakaznici']:''; ?></p>
</div>
<div class="form-group">
<label>Meno:</label>
<p><?php echo !empty($zakaznici['meno'])?$zakaznici['meno']:''; ?></p>
</div>
<div class="panel-body" align="center">Graph will be displayed here</div>
<div class="form-group">
<label>Priezvisko:</label>
<p><?php echo !empty($zakaznici['priezvisko'])?$zakaznici['priezvisko']:''; ?></p>
</div>
<div class="form-group">
<label>Email:</label>
<p><?php echo !empty($zakaznici['email'])?$zakaznici['email']:''; ?></p>
</div>
<div class="form-group">
<label>Adresa:</label>
<p><?php echo !empty($zakaznici['adresa'])?$zakaznici['adresa']:''; ?></p>
</div>
<a class="btn btn-primary" href="<?php echo site_url('Zakaznici/viewusersvypozicky/'.$zakaznici['ID_zakaznici']); ?>" role="button">Zobraziť prenájmy</a>
</div>
</div>
</div>

p tags create line breaks. You could replace the p tag with a span tag to remove the unwanted break.
Your div with the class name 'panel-body' is also occupying space. You could add position: absolute; to its defined styles and it would not create that break.
<div class="row">
<div class="panel panel-default">
<div class="panel-heading">Detail zákazníka </div>
<div class="panel-body">
<div class="form-group">
<label>ID zákazníka:</label>
<p><?php echo !empty($zakaznici['ID_zakaznici'])?$zakaznici['ID_zakaznici']:''; ?></p>
</div>
<div class="form-group">
<label>Meno:</label>
<span><?php echo !empty($zakaznici['meno'])?$zakaznici['meno']:''; ?></span>
</div>
<div class="panel-body" align="center">Graph will be displayed here</div>
<div class="form-group">
<label>Priezvisko:</label>
<p><?php echo !empty($zakaznici['priezvisko'])?$zakaznici['priezvisko']:''; ?></p>
</div>
<div class="form-group">
<label>Email:</label>
<p><?php echo !empty($zakaznici['email'])?$zakaznici['email']:''; ?></p>
</div>
<div class="form-group">
<label>Adresa:</label>
<p><?php echo !empty($zakaznici['adresa'])?$zakaznici['adresa']:''; ?></p>
</div>
<a class="btn btn-primary" href="<?php echo site_url('Zakaznici/viewusersvypozicky/'.$zakaznici['ID_zakaznici']); ?>" role="button">Zobraziť prenájmy</a>
</div>
</div>
</div>

Try this
<div class = "row">
<div class = "panel panel-default col-4">
<div class = "panel-body">
//your matter
</div>
</div>
<div class = "panel panel-default col-4">
<div class = "panel-body">
//your graph
</div>
</div>
</div>

As discussed the p's are block level elements and create linebreaks - but Bootstrap also stlyes them with a 10px margin bottom so you may want to overwrite that with
p { margin-bottom: 0;}
I do not recommend this - the ideaa of the margin bottom is to separate text elements.
What will be causing your space issue where you have indicated is that you are using a div with a .panel body class within the panel body.
<div class="panel-body" align="center">Graph will be displayed here</div>
Bootstrap styles the panel body with 15px padding - so either
a) replace that class with a different class (this is what I would do - it makes no sense to have a .panel-body -within a .panel-body)
b) remove the padding from the nested panel body
.panel-body > .panel-body { padding: 0}
But as I said - a panel body within another one is semantically wrong.

Related

Move the widget to the right side of the web page using bootstrap 4

I want the information tag to be at the right side of the web page. Rest of the things are in the middle of the page. While I am not able to move the information to the right side. Also, because of it the footer disappeared. While I remove the information code, the footer works. Please help me right-align the information widget and also have the footer too.
<div class="container">
<div class="card border-light mb-3 text-center">
<p class="card-header">Videos</p>
</div>
<div id="userSuccess" class="hide" role="alert">
<div id="successUserContent"></div>
</div>
<div class="row" id="userVid">
<?php
$allVid = Schema::getAll();
for ($i = 0; $i < count($allVid); $i++) {
echo <<<HTML
<div class="col-lg-4 col-md-6 mb-4">
<div class="card h-100">
<div class="card-body">
<img class="card-img-top" src="http://placehold.it/700x400" alt="">
<h4 class="card-title">{$allVid[$i]->getTitle()} </h4>
</div>
</div>
</div>
HTML;
}
?>
</div>
<div class="row">
<div class="col-md-4 order-md-2 mb-4">
<div class="card my-4">
<h5 class="card-header">Information</h5>
<div class="card-body">
<div class="row">
<ul class="list-unstyled mb-0">
<li>
...
</li>
</ul>
</div>
</div>
</div>
</div>
</div>
</div>
<?php
require_once './page/footer.php';
?>
For right align, you'll want to add the class of "justify-content-end" after your "row" class.
<div class="row justify-content-end"><!-- ADDED HERE-->
<div class="col-md-4 order-md-2 mb-4">
<div class="card my-4">
<h5 class="card-header">Information</h5>
<!-- REST OF YOUR CODE-->
For your footer, you'll need to wrap your URL in parenthesis.
<?php require_once('/yourdirectory/yourfooter.php'); ?>

How to divide divs into columns and wrap and image within

I am attempting to create a profile page that has a number of div's that I need to divide into two columns with an image at the top. I have the image displayed fine but I can't seem to get the information to separate into two columns... at the moment it's all flowing down the page.
Below is my code that I am developing in cakephp:
<!--Profile Code-->
<div class="users view large-9 medium-8 columns content">
<div class="row">
<!--box style-->
<div class="panel panel-default">
<!--whitespace around panel-->
<div class="panel-body">
<div>
<h4 style="color:#00b1b1;"><?= h($user->name) ?></h4>
</div>
<div class="box box-info">
<div class="box-body">
<div align="left"><img height="200px" width="200px" alt="Users Picture" src="">
<input id="profile-image-upload" class="hidden" type="file">
</div>
<div class="col-sm-5">First Name: </div><div class="col-sm-4"><?= h($user->first_name) ?></div>
<div class="col-sm-5">Last Name:</div><div class="col-sm-4"> <?= h($user->last_name) ?></div>
<div class="col-sm-5">Username:</div><div class="col-sm-4"> <?= h($user->username) ?></div>
<div class="col-sm-5">Email:</div><div class="col-sm-4"> <?= h($user->email) ?></div>
<div class="col-sm-5">Role:</div><div class="col-sm-4"><?= h($user->role) ?></div>
<div class="col-sm-5">User ID:</div><div class="col-sm-4"><?= $this->Number->format($user->id) ?></div>
<div class="col-sm-5">Created:</div><div class="col-sm-4"><?= h($user->created) ?></div>
<div class="col-sm-5">Modified:</div><div class="col-sm-4"><?= h($user->modified) ?></div>
<div class="col-sm-5">Active:</div><div class="col-sm-4"><?= $user->active ? __('Yes') : __('No'); ?></div>
<!-- /.box-body -->
</div>
<!-- /.box info -->
</div>
</div>
</div>
</div>
<script>
$(function() {
$('#profile-image1').on('click', function() {
$('#profile-image-upload').click();
});
});
</script>

bootstrap 4 grid mixed up when using margin

I am generating html code using php. I have some information stored in an array called $persons and I'm trying to generate a bootstrap card for each $person:
<div class="container">
<div class="row">
<?php foreach ($persons as $person): ?>
<div class="card col-md-3 m-1">
<img class="card-img-top" src="<?=person['img_src']?>" alt="<?=$person['name']?>">
<div class="card-block">
<h4 class="card-title"><?=$person['name']?></h4>
<p class="card-text"><?=$person['info']?></p>
</div>
</div>
<?php endforeach; ?>
</div>
</div>
Everything works fine when I remove m-1 class, but as soon as I add m-1 class, margin causes the last div to go to next line. I think lack of space causes this problem. How can I fix this problem? How to have margin between divs without the last div going to the next line?
You should have a separate div for the card since it's display:flex. Also, just use my-1 for margin-top and margin-bottom so that x-axis space is not effected...
<div class="container">
<div class="row">
<?php foreach ($persons as $person): ?>
<div class="col-md-3 my-1">
<div class="card">
<img class="card-img-top" src="<?=person['img_src']?>" alt="<?=$person['name']?>">
<div class="card-block">
<h4 class="card-title"><?=$person['name']?></h4>
<p class="card-text"><?=$person['info']?></p>
</div>
</div>
</div>
<?php endforeach; ?>
</div>
</div>
https://www.codeply.com/go/78AmkbWrLi
The easiest solution would be to just put another div inside the col, which applies the margin:
<div class="container">
<div class="row">
<?php foreach ($persons as $person): ?>
<div class="card col-md-3">
<div class="m-1"> <!-- NEW -->
<img class="card-img-top" src="<?=person['img_src']?>" alt="<?=$person['name']?>">
<div class="card-block">
<h4 class="card-title"><?=$person['name']?></h4>
<p class="card-text"><?=$person['info']?></p>
</div>
</div>
</div>
<?php endforeach; ?>
</div>
</div>
Or if you don't want to add another div, just add the m-1 class to the card-block.

CakePHP custom setFlash

I've read on the CakePHP Book that you can define your own custom setFlash messages using an element... but what I would I put inside the element and how would I pass different content.
So for example two different messages:
<div id="flashMessage" class="message">
<div class="content">
<p>Please correct the errors</p>
</div>
</div>
<div id="flashMessage" class="announcement message">
<div class="content">
<h3>Announcement</h3>
<p>You have earned a new achievement</p>
</div>
</div>
So as you can see I want to define a wrapper div and a content div and then also pass in an additional class if need be dependant on the kind of message and also show different content such as just a paragraph or a header and a paragraph.
Can anyone help? Thanks
You can have two elements:
myflash.ctp
<div id="flashMessage" class="message">
<div class="content">
<p><? echo $message ?></p>
</div>
</div>
announcement.ctp
<div id="flashMessage" class="announcement message">
<div class="content">
<h3>Announcement</h3>
<p><? echo $message ?></p>
</div>
</div>
and then:
$this->Session->setFlash($message,'myflash or announcement');
or one element:
myflash.ctp
<div id="flashMessage" class="<? echo (isset($myclass)?$myclass.' ':'') ?>message">
<div class="content">
<? echo (isset($header)?'<h3>' . $header.'</h3>':'') ?>
<p><? echo $message ?></p>
</div>
</div>
and at your controller:
$this->Session->setFlash($message,'myflash',array('myclass'=>'announcement','header'=>'Announcement');

Splitting article on multiple images

I got an article that is read from the database. Which is in a wrapper, I needed an image to be full width (so even wider than the wrapper) while still being in the article. So I split it on the image tag like the code below.
However this prevents a user from adding multiple images. When I add another image tag it doesn't show the image.
How can I split the article not just on one image but every image?
All data (text, img tags) is in 'introtext'.
For example:
<p>Part one of the article</p>
//Here the article is split on all img tags that are there.
<img src="#">
<img src="#">
<img src="#">
<img src="#">
<p>Part two of the article</p>
The below code only works when I add one image tag.
<div class="container relative" style="padding: 0px;">
<div class="row">
<div class="col-sm-12">
<div class="blog-item mb-20 mb-xs-40">
<!-- Text -->
<div class="blog-item-body">
<?
$introtext = $contenti[0]['introtext'];
$splitartikel = preg_split('/(<img[^>]+\>)/i', $introtext, -1, PREG_SPLIT_DELIM_CAPTURE);
echo $splitartikel[0];
?>
</div>
</div>
</div>
</div>
</div>
<div class="container-fluid relative" style="padding: 0px;">
<div class="row">
<div class="col-sm-12">
<div class="middleimage">
<?
echo $splitartikel[1];
?>
</div>
</div>
</div>
</div>
<div class="container relative" style="padding: 0px;">
<div class="row">
<div class="col-sm-12">
<div class="blog-item mb-20 mb-xs-40">
<!-- Text -->
<div class="blog-item-body">
<?
echo $splitartikel[2];
?>
</div>
</div>
</div>
</div>
</div>
The query:
// Articles
$content = "SELECT * FROM `lb_content` WHERE alias = '".$conn->real_escape_string($_GET['alias'])."' ";
$contentcon = $conn->query($content);
$contenti = array();
while ($contenti[] = $contentcon->fetch_array());
I also tried looping the middle part, but this also loops the text before and after the image, while I only want to have the option to have multiple images.
Like this:
<?php foreach($splitartikel as $part) : ?>
<div class="container-fluid relative" style="padding: 0px;">
<div class="row">
<div class="col-sm-12">
<div class="middleimage">
<?php echo $part; ?>
</div>
</div>
</div>
</div>
<?php endforeach ?>
Maybe I need to do some sort of foreach loop for every image tag?

Categories