On mobile, the content goes out off the page, and the horizontal scrollbar shows up.
You can check my page on this link.
<div class="custom_content col-md-12">
<div class="container">
<div class="row">
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item">Kezdőlap</li>
<li class="breadcrumb-item"><?php echo $pageTitle; ?></li>
</ol>
</nav>
</div>
<div class="row">
<h1 class="page_title"><?php echo $pageTitle; ?></h1>
</div>
<div class="row">
<div class="content"><?php GetContent($siteID); ?></div>
</div>
</div>
</div>
You required to add one additional div with class col right after the row.
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet" />
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet" />
<div class="custom_content col-md-12">
<div class="container">
<div class="row">
<div class="col-12">
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item">Kezdőlap</li>
<li class="breadcrumb-item">
<a href="<?php echo $host; ?>/<?php echo $pageSeo; ?>" title="<?php echo $pageTitle; ?>">
<?php echo $pageTitle; ?>
</a>
</li>
</ol>
</nav>
</div>
</div>
<div class="row">
<div class="col-12">
<h1 class="page_title">
<?php echo $pageTitle; ?>
</h1>
</div>
</div>
<div class="row">
<div class="col-12">
<div class="content">
<?php GetContent($siteID); ?>
</div>
</div>
</div>
</div>
</div>
<section class="custom_content">
<div class="container">
<div class="row">
<div class="col-12">
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item">Kezdőlap</li>
<li class="breadcrumb-item"><?php echo $pageTitle; ?></li>
</ol>
</nav>
</div>
</div>
<div class="row">
<div class="col-12">
<h1 class="page_title"><?php echo $pageTitle; ?></h1>
</div>
</div>
<div class="row">
<div class="col-12">
<div class="content"><?php GetContent($siteID); ?></div>
</div>
</div>
</div>
</section>
Your markup is wrong! As you didn't provide CSS code I have only fixed your layout.
You should've used .container > .row > .col-*-*
Containers provide a means to center and horizontally pad your site’s contents. Use .container for a responsive pixel width or .container-fluid for width: 100% across all viewport and device sizes.
Rows are wrappers for columns. Each column has horizontal padding (called a gutter) for controlling the space between them. This padding is then counteracted on the rows with negative margins. This way, all the content in your columns is visually aligned down the left side.
In a grid layout, content must be placed within columns and only columns may be immediate children of rows.
For reference go through bootstrap grid system
Place your container tag out to row and col tags.
It should be like:
<div class="container">
<div class="row">
<div class="col-sm-12">
</div>
</div></div>
It will fix it!
In other cases, follow below:
<meta name="viewport" content="width=device-width, initial-scale=1.0">
Add this tag in your code, and the page will be responsive based on the screen size.
Related
I have two divs [one is upper | second is lower]. Both can fetch data from database and make accordingly number of divs. lower div is default hidden. I want to show lower div when I click upper div. jquery code that i make is here. Need your help.
Note. Show only current active lower div. All other lower divs must hidden. to do this
<!---upper div section--->
<?php
$id=1;
while ($comp_post_info=mysqli_fetch_array($query))
{
?>
<div class="container-fluid">
<div class="row">
<div class="upperdiv container-fluid mb-5">
<div class="row">
<div class="col-md-1 pdl-3">
<i class="fa fa-circle"></i>
</div>
<div class="col-md-11">
<div class="container-fluid">
<div class="row jlist" id="addbg">
<div class="col-md-4">
<img src="/my_brands/brand.png" alt="" class="cust-em">
<h6><?php echo $comp_post_info['title'] ?> <p><small><?php echo $comp_post_info['c_name'] ?></small></p></h6>
</div>
<div class="col-md-4">
<h6>
<?php echo $comp_post_info['state'] ?>,<?php echo $comp_post_info['coun'] ?>
<p><small>Location</small></p>
</h6>
</div>
<div class="col-md-4">
<h6>
<?php echo $comp_post_info['saly'] ?>
<p><small> Saly</small></p>
</h6>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!----lowerdiv--->
<div class="lowerdiv container-fluid hideme" id="mydiv" >
<div class="row pt-4 padl-5">
<h6>Other Prepositions <small>for gle</small></h6>
</div>
<div class="row">
<div class="col-md-11 offset-md-1">
<div class="container-fluid">
<div class="row sub_lowerdiv pt-2">
<div class="col-md-4">
<i class="fa fa-circle"></i>
<h6><?php echo $comp_post_info['title'] ?> <p><small><?php echo $comp_post_info['c_name'] ?></small></p></h6>
</div>
<div class="col-md-4">
<h6>
<?php echo $comp_post_info['state'] ?>,<?php echo $comp_post_info['count'] ?>
<p><small>Location</small></p>
</h6>
</div>
<div class="col-md-4">
<h6>
<?php echo $comp_post_info['saly'] ?>
<p><small>Saly</small></p>
</h6>
</div>
</div>
</div>
</div>
</div>
</div>
<?php
}
?>
** <script>
$(document).ready(function(){
$(".upperdiv").on("click",function(){
var currentselect = $(this).('.lowerdiv');
$(".lowerdiv").not(currentselect).hide();
currentselect.show();
});
});
</script> **
enter code here
Use closest to find the parent (I have added parent class .parent-div) and then use nextAll to find the first lowerdiv.
See the Snippet below:
$(document).ready(function(){
$(".upperdiv").on("click",function(){
var currentselect = $(this).closest(".parent-div").nextAll('.lowerdiv').first(); /* Look I've added find */
$(".lowerdiv").not(currentselect).hide();
currentselect.show();
});
});
.lowerdiv{
display: none;
margin-left: 15px;
}
.upperdiv{
cursor: pointer;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="parent-div container-fluid">
<div class="row">
<div class="upperdiv">
Upper 1
</div>
</div>
</div>
<div class="lowerdiv">
Lower 1
</div>
<div class="parent-div container-fluid">
<div class="row">
<div class="upperdiv">
Upper 2
</div>
</div>
</div>
<div class="lowerdiv">
Lower 2
</div>
<div class="parent-div container-fluid">
<div class="row">
<div class="upperdiv">
Upper 3
</div>
</div>
</div>
<div class="lowerdiv">
Lower 3
</div>
I'm designing a side list-group of recent blogs with bootstrap 4 in my angular application but facing some problems when the aspect ratio is changed to mobile view. In some mobile view the images are resizing and getting smaller to fit into the div as the title gets bigger. I want the title to resize and if it's too long, then should break and get into next line but all the image size should remain same. Also I want the image to take the full height of the element. Please look at the image below to have a better understanding.
HTML:
<div class="container">
<div class="row">
<div class="col-12">
<h6 class="text-muted">Recent Blogs</h6>
<ul class="list-group" *ngFor="let blog of blogs">
<li class="list-group-item d-flex justify-content-between align-items-center">
<div class="image-parent">
<a [routerLink]="['/blog', blog.blogId]">
<img src="http://localhost:4000/{{blog.imagePath}}" class="img-fluid" alt="lay">
</a>
</div>
<a [routerLink]="['/blog', blog.blogId]">
{{blog.title}}
</a>
</li>
</ul>
</div>
</div>
</div>
Change your code like this. It'll help
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">
<div class="container">
<div class="row">
<div class="col-md-12">
<h6 class="text-muted">Recent Blogs</h6>
<ul class="list-group" *ngFor="let blog of blogs">
<li class="list-group-item d-flex justify-content-between align-items-center">
<div class="row">
<div class="col-md-4">
<div class="image-parent">
<a>
<img src="https://cdn.pixabay.com/photo/2015/12/01/20/28/road-1072823__340.jpg" class="img-fluid" alt="lay">
</a>
</div>
</div>
<div class="col-md-8">
<a>
Text Test
</a>
</div>
</div>
</li>
</ul>
</div>
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"></script>
I'm Struggling adjusting my articles here :
https://cryptoranger.net/news
I'm using bootstrap 4.3.0, here's the code of the rows :
<div class="row bg-light">
<?php
foreach ($newsList as $news){?>
<article class="col-md-4 blogpost border rounded p-0">
<div class="imgBx">
<img src="/images/<?=$news['image'] ?>" alt="" class="img-fluid">
</div>
<div class="content">
<h2 class="itemrecent1"><?= $news['titre'] ?></h2>
<p class="float-left m-0"><i class="fas fa-clock"></i> <?= $news['dateAjout']->format('Y-m-d') ?></p><br>
<p class="itemrecent1"><?= nl2br($news['contenu']) ?></p>
<?php
if ($category === 'news'){?>
<div class="itemrecent1">Read</div>
<?php
}else {?>
<div class="itemrecent1 justify-self-end">Read</div>
<?php
}?>
<div class="clearfix"></div>
</div>
</article>
<?php } ?> <!-- End of news -->
</div>
So i want gutters between my articles...
Besides, if you know how to adjust the content (text inside the box because i tried some flexbox css but nothing is changing (i want at least all Read link at the same level (bottom))...
==> It's working if i put some height in pixel but cant do that because i need responsive design..
Thanks... :D
The gutters are there, they come from the padding on the col-* classes. Because you added the border class to your articles the padding is, naturally, surrounded by a border. Usually when using Bootstrap grid layouts, content is placed within a wrapper element that has the desired col-* class:
<div class="row bg-light">
<?php
foreach ($newsList as $news){?>
<div class="col-md-4">
<article class="blogpost border rounded p-0">
<div class="imgBx">
<img src="/images/<?=$news['image'] ?>" alt="" class="img-fluid">
</div>
<div class="content">
<h2 class="itemrecent1"><?= $news['titre'] ?></h2>
<p class="float-left m-0"><i class="fas fa-clock"></i> <?= $news['dateAjout']->format('Y-m-d') ?></p><br>
<p class="itemrecent1"><?= nl2br($news['contenu']) ?></p>
<?php
if ($category === 'news'){?>
<div class="itemrecent1">Read</div>
<?php
}else {?>
<div class="itemrecent1 justify-self-end">Read</div>
<?php
}?>
<div class="clearfix"></div>
</div>
</article>
</div>
<?php } ?> <!-- End of news -->
</div>
Looks like you actually have it correct on another page on your site
I seem to be having difficulties with a bootstrap carousel it seems to "Break" outside of the container / row. I'm not 100% sure of what kind of information I may need to provide (First time posting here for help) But here is a screenshot followed by the code (Just a typical bootstrap carousel resized)
Screenshot of error
.project01-carousel {
width:640px;
height:360px;
}
<div class="col-sm-4">
<section class="project01-carousel halfheight">
<section class="project-carousel-wrap halfheight">
<!-- Carousel -->
<div class="project-carousel owl-carousel owl-nav-sticky-wide">
<div class="project-carousel-item project-01-carousel-item-01 halfheight
text-center">
<img src="admin/uploaded_image/terrain_renders/<?php echo $row['render1'];
?>">
</div>
<div class="project-carousel-item project-01-carousel-item-02 halfheight
text-center">
<img src="admin/uploaded_image/terrain_renders/<?php echo $row['render2'];
?>">
</div>
<div class="project-carousel-item project-01-carousel-item-03 halfheight
text-center">
<img src="admin/uploaded_image/terrain_renders/<?php echo $row['render3'];
?>">
</div>
<div class="project-carousel-item project-01-carousel-item-04 halfheight
text-center">
<img src="admin/uploaded_image/terrain_renders/<?php echo $row['render4'];
?>">
</div>
</div>
</section>
</section>
</div>
Make sure you don't have a static width for your content, and I notice you are using Owl Carousel in Bootstrap, so make sure you aren't duplicating any classes there/have Bootstrap carousel styles and js turned off so there's no conflicts.
Please note, I only used !important to overcome an img style that was overriding my 100% width call for it. You shouldn't have to use the !important tag in your code.
.project01-carousel {
/*width:640px;*/
width: 100%;
max-width: none;
height:auto;
border: 1px solid red;
}
img {
width: 100% !important;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<div class="col-sm-4">
<section class="project01-carousel halfheight">
<section class="project-carousel-wrap halfheight">
<!-- Carousel -->
<div class="project-carousel owl-carousel owl-nav-sticky-wide">
<div class="project-carousel-item project-01-carousel-item-01 halfheight
text-center">
<img src="http://placehold.it/500x500">
</div>
<div class="project-carousel-item project-01-carousel-item-02 halfheight
text-center">
<img src="http://placehold.it/500x500">
</div>
<div class="project-carousel-item project-01-carousel-item-03 halfheight
text-center">
<img src="http://placehold.it/500x500">
</div>
<div class="project-carousel-item project-01-carousel-item-04 halfheight
text-center">
<img src="http://placehold.it/500x500">
</div>
</div>
</section>
</section>
</div>
First of all,you should wrap your
<div class="col-sm-4">
In a row and wrap the row in a container like this
<div class="container-fluid">
<div class="row">
<div class="col-sm-4">
And also you should remove the width for
roject01-carousel
I am trying to center the content but my content is going on the right side and goes off the screen
Here is my code:
<?php
/* Template Name: About Us
*/
$aboutheading = get_field('about_heading');
$aboutus = get_field('about_us');
get_header(); ?>
<section>
<div class="container">
<div class="row">
<div class="col-md-4">
<h2> <?php echo "$aboutheading"; ?></h2>
</div>
</div>
</div>
<div class="container">
<div class="row">
<div class="col-sm-4 col-md-6">
<p class="lead"><?php echo "$aboutus"; ?></p>
</div>
</div>
</div>
</section>
<?php get_footer(); ?>
Here is the live link:http://www.abiglittlebiz.com/trevelle/about-us/
what I'm trying to achieve that the div becomes responsive
You have in your $aboutus Non-Breaking Space
In this case, text can't be break and go to new line. Clear Non-Breaking Spaces from your content or try this:
<p class="lead"><?php echo str_replace(' ', ' ', $aboutus); ?></p>
As others have pointed out in the comments. The issue is not CSS. The issue is the content. All spaces have been replaced by in your content, which is keeping the browser from breaking lines.
Just to verify this you can add the rule word-break: break-word; to your div and notice that the lines will be forced to break mid-word and stay inside your div.
You need to use offset class.
<section>
<div class="container">
<div class="row">
<div class="col-md-offset-4 col-md-4">
<h2> <?php echo "$aboutheading"; ?></h2>
</div>
</div>
</div>
<div class="container">
<div class="row">
<div class="col-sm-offset-4 col-md-offset-3 col-sm-4 col-md-6">
<p class="lead"><?php echo "$aboutus"; ?></p>
</div>
</div>
</div>
</section>