Shushovan's avatar

@include creates a gap like a 10px margin

I am new to Laravel. Therefore I am creating an e-commerce website to learn Laravel. But whenever I am using @include to include header.blade.php it's creating a margin button(approx 10px I guess). I have used @extends as well but same problem. I am unable to fix this problem. Please suggest me to short out this problem.

0 likes
6 replies
Shushovan's avatar

Yes.

I have created three pages. 1st one is header, 2nd is the body content of the dashboard and 3rd one is the footer.

Inside the index.blade.php file, I have included these 3 files. The code is given below...

@include('admin.dashboard.master'); @include('admin.dashboard.dashboard-content'); @include('admin.dashboard.footer');

When I am browsing the page I am getting a gap after the header and the footer.

Shushovan's avatar

@MICK79 - Yes.

I have created three pages. 1st one is header, 2nd is the body content of the dashboard and 3rd one is the footer.

Inside the index.blade.php file, I have included these 3 files. The code is given below...

@include('admin.dashboard.master'); @include('admin.dashboard.dashboard-content'); @include('admin.dashboard.footer');

When I am browsing the page I am getting a gap after the header and the footer.

Cronix's avatar

Could it be the spaces in between your includes? The first char of the included file will get placed where the @ is for the @include(file)

Shushovan's avatar

Yes. In core php there was no problem to include any other pages. But here I don't know why the problem occuring. The Gap is occurring after the header that means below header and below footer.

Cronix's avatar

You'd have to show your layout file, and the content of the 3 included files in order to help more.

I tend to put the includes on their own lines, and the includes are fully closed markup blocks, which usually avoids the problem. It's not a problem with the include system as it's basically the same as a native php include. It's the markup of the included files, and where/how they are placed that matters. What does the html source of the page look like after it's sent to your browser?

What I mean by fully closed markup blocks is I'd never have a view with

<div>
     <ul>

where the closing div and ul elements aren't present. They would both have closing tags. If everything is closed properly, then it doesn't matter where you place the @includes.

Please or to participate in this conversation.