Css Position Relative/Absolute is disturbing the Layout [closed] - html

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 years ago.
Improve this question
Please checkout the following fiddle
HTML structure and Css is almost same. that i am using in my project.
Currently i have 3 sections in my design
HEADER
Portfolio
Slider Troubling section
I am using bootstrap 3 latest version.
I have given position relative to Portfolio section and its inner block to position absolute with top: -50px;
Every thing is fine here. but problem comes when i add new section "Slider". It is coming over the Portfolio section. I have tried giving it position and different block properties. but still slider section is coming over the portfolio section. When i remove Positions from Portfolio section
the Slider section goes back to it normal position which is what i want.
Can anyone please check the following fiddle and tell me what i am doing wrong.
Design is like that Portfolio section is little bit over the header. that's why i am using position.
<script async src="//jsfiddle.net/DTcHh/29616/embed/"></script>
https://jsfiddle.net/DTcHh/29616/

I'd rather not use position: absolute where it's not needed because it breaks the flow. You need only position relative or negative margin-top to move the element up. See example https://jsfiddle.net/DTcHh/29623/
<header class="container-fluid header">
<div class="row">
<h1>HEADER</h1>
</div>
</header>
<section class="container">
<div class="row position-relative">
<div class="col-sm-10 col-sm-offset-1 position-relative-col">
<div class="height">
<h2>Some Portfolio items here</h2>
</div>
</div>
</div>
</section>
<section class="container trouble">
<div class="row">
<h3>Slider Troubling section</h3>
</div>
</section>
/* Latest compiled and minified CSS included as External Resource*/
/* Optional theme */
#import url('//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap-theme.min.css');
.header {
background: lightblue;
padding:25px;
}
.position-relative {
position:relative;
}
.position-relative-col {
background: green;
position: relative;
top: -50px;
}
.trouble {
background: darkblue;
opacity: 0.8;
color: white;
}
.height {
height: 100px;
}

try add to the container class height property. It should work:
.container{
height: 100px;
}

Check my update I hope it helps.
http://jsfiddle.net/DTcHh/29626/
what I did are put the slider and portfolio into the same tag that using position:relative and top: -50px;

You are using the bootstrap 3 grid wrong. For each row you have to add a row class and for each item in the row class you have to use the class col-*-*. I have written based on your code some new code with the proper use of bootstrap grid.
http://jsfiddle.net/DTcHh/29627/
Please let me know if this is not good, and what you try to achieve instead.

Related

How can I align everything together in a div? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
image
this is my first post here and I'm trying to figure out how I can do something like that
thanks in advance
I would use flexbox in CSS. once you lean this it will be a tool you use a lot for this type of thing. when you use flexbox there is a container element. i would use a div. see my example.
<!--HTML-->
<html>
<div id="container">
<div class="box"></div>
<div class="box"></div>
<div class="box"></div>
<div class="box"></div>
</div>
</html>
the divs that are "class" of "box" are the no1 and no2 paragraphs. in CSS use:
/*CSS*/
#container {
display: flex;
flex-direction: row;
}
you'll just need to format the class of box which will format each of the elements in that class (4 in my example above)
use this cheat sheet and you'll be a pro at this in no time.
https://www.steveaolsen.com/docs/FlexboxCheatsheet.pdf
also, view the page source you want to copy, it will all be there for you to see.
good luck
In addition to what sao said, a more basic way would be using display's inline or inline-block properties:
.box {
display: inline-block;
}
<div>
<div class="box">X</div>
<div class="box">X</div>
<div class="box">X</div>
</div>
It should do the trick, but I agree that using flex is a better and more advanced way to do so.
Also, I'd recommend searching a bit more for your question before asking it, I'm sure this question has been asked before.
Best of luck mate!
you've got many options depending on wether or not you intend for it to be only text, images .. and how adaptable you want it to be in the future.
here is a simple way that doesn't require advanced CSS:
.container { /*attributes of "div" weating the "container" class*/
display: flex;
width: 500px; /*make it 500pixels wide*/
}
.box {
width: 50%; /*all "box" will have a width of 50% it's parent (container here)*/
padding: 10px; /*give some cushion on the sides*/
}
.box:first-child { /*select only the first "box", very powerful*/
border-right: 1px solid red; /*right border to delimit*/
}
<div class="container"> <!--wide container in which both boxes go in-->
<div class="box"><!--1st box-->
<p>Your first text goes here and it goes on and on and on and on and on and forever....</p><!--1st text-->
</div><!--close 1st box-->
<div class="box"><!--2nd blox-->
<p>Your second text goes here and it goes on and on and on and on and on and forever....</p><!--2nd text-->
</div><!--close 2nd box-->
</div><!--close wide container box-->
The possibilities from here are endless. Visit a trusted site on HTML/CSS/JS coding to get started. I'm personally keen on Mozilla
Your most useful tool will be the "inspector", on any modern browser today you have the possibility to change CSS code and play around, discover what works and what doesn't. It doesn't affect anyone but you, on the page you're visiting, for example :
I used Flex in the example, but it's only one of the many options. With CSS there are often more than 2 ways to produce 1 result. Always go for the one with less code and less specific (more open ended to future changes)
Now hope your curiosity is tickled, get out there, learn & code !
I'm trying to figure out how I can do something like that
You have multiple options. From approximate worst to approximate best:
HTML tables (https://www.w3schools.com/html/html_tables.asp)
CSS absolute positioning (https://css3-tutorial.net/positioning/absolute/)
CSS tables (https://colintoh.com/blog/display-table-anti-hero)
CSS floats (https://www.w3schools.com/css/css_float.asp)
CSS Columns (https://www.w3schools.com/css/css3_multiple_columns.asp)
CSS Flexbox (https://css-tricks.com/snippets/css/a-guide-to-flexbox/)
CSS Grid (https://css-tricks.com/snippets/css/complete-guide-grid/)

Blank space going off-screen [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 5 years ago.
Improve this question
I am trying to fix the following issue on this website: http://santanna.beutifi-website.com/
Notice that there is a blank space to the right as if the page has a wider width or margin, although after checking these features, I could not figure out what the problem is. It does not happen on mobile devices though.
I played with developer tools for quite a while and no luck, I was wondering if any of you might be able to see whats wrong...
Cheers!
I started writing what #Matthew said but since you're using WordPress it's probably better to just overwrite the style. Try this:
.copyright{
margin-left: 0 !important;
}
.copyright p{
text-align:center !important;
}
Add that to custom styles of the theme if possible. Good luck!
The issue only shows when you make the screen size smaller. It is being caused by your css below:
#media only screen and (min-width: 840px) (index):175
.copyright {
margin-left: 25%; */
}
When I remove that it solved the problem.
If you want your text to be centered you can either remove the text-left class you have on that div and center it manually or you can add text-align: center !important to your copyright class after you remove the margin.
Edit:
Also you should not double up on the .container classes like you have below. Either use one or the other.
<div class="container-fluid bg-dark-gray footer-bottom">
<div class="container">
<div class="row margin-three">
<!-- copyright -->
<div class="col-md-12 col-sm-12 col-xs-12 copyright text-left letter-spacing-1 xs-text-center xs-margin-bottom-one light-gray-text2">
<p align="left" style="font-size:11px;text-transform:uppercase;color:#939598;width: 100% !important;">Copyright © 2017. Built & managed by <span style="color:#56c7cc;">BEUTiFi.com</span> All rights reserved.</p>
</div>
<!-- end copyright -->
</div>
</div>
</div>
It's a problem with the css in the .
the .container class item is set to a pixel width;

How to make a limited size page-spanning background in html/css [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
I am a self taught coder developing a website for a nonprofit I've founded, and would like to have a footer to thank the sponsors of said nonprofit. I'm trying to distinguish this section from the rest of the site by changing its background color relative to the rest of my webpage. I've tried everything I can think of, like creating a div/footer with a width of 100% and a different background-color, but that only adds background colors to the portions of the div that contain text (the text appears to be highlighted with this color, rather than the color being a solid background applied to the entire div). All of my research has only turned up results for either how to make the entire background of a page a specific color, or how to add styles to horizontal rules, neither of which help me (the former because I want the color to differ from that of the rest of the page, and the latter because I am unable to put the content/text I would like to include over it). If anyone could help, it would be much appreciated. Thank you!
Edit: Clarification has been requested. Essentially, I was creating a footer for my website that I wanted to look like the one here with that black bar at the bottom that spans the page. My issue was that the div I was creating didn't span the page well enough to make it a solid bar; it was more of a blocky coloring that only showed up in nested divs containing text. I posted this question because I wasn't able to find any guides on how to span the page with a footer like this, but adding a nested div with the color background I wanted and a width of 100vm, setting the margins to 0, and hiding overflow ultimately let me accomplish my intent. Hopefully this is adequate clarification. I'd also appreciate if the downvote I accrued were removed, or at least explained; it's difficult to improve my posts if I don't know the issue with them
It's kind of hard to tell what the exact issue is without a visual example of your issue. But from the sounds of it, you want the background to extend the entire width of the page, but don't want the actual content to extend the entire width.
To do this, I would introduce a class that represents the width you want your content to be, and put that class nested within the footer (and any other elements on the page) where you want the parent (ie, the footer) to extend the width of the page, and everything inside the footer to be contained within the width that you want the content to be displayed. Here is an example, where the class I"m referring to is .viewport. Assigning a background to your footer and nesting .viewport within the footer will give the footer a full-width background, while leaving the text nested within the footer at your specified width.
body {
margin: 0;
}
header {
background: #eee;
}
.viewport {
max-width: 960px;
width: 90%;
margin: auto;
}
footer {
background: #171717;
color: #fff;
}
.section {
padding: 2em 0;
}
<header class="section">
<h1 class="viewport">
This is a header
</h1>
</header>
<main class="section">
<div class="viewport">
<p>hello world</p>
<p>hello world</p>
<p>hello world</p>
<p>hello world</p>
<p>hello world</p>
</div>
</main>
<footer class="section">
<p class="viewport">This is a footer</p>
</footer>
Here is a quick fix for you:
HTML
<div class="Footer">
<div class="Content">Place you stuff here</div>
</div>
CSS
.Footer{position:relative; width:100%; height:100px; display:block; float:left; background-color:RED;}
.Footer > .Content{position:relative; margin:auto; width:80%; height:100%;}
The best and easiest solution is with bootstrap but since you didnt mention it that means you are not using it.
<footer>
<div class="sponsors">
Type anything you want
</div>
</footer>
CSS:
.sponsors{
text-align:center;
background-color:(your color);
}
This should work, if not tell me what went wrong!

Bootstrap Jumbotron not becoming full width of Body

Hi I am trying to fix my Jumbotron to be full width of the screen but somehow it need a 15px padding-left, padding-right. If I remove the padding the horizontal scrollbar appears with a 30px right margin. I am using the default Bootstrap ver 3.0.3 and default VS2013 layout. As per this link I removed the Jumbotron outside all .container my page looks sth like this
<body>
<div class="navbar navbar-inverse navbar-fixed-top">.... Navigation stuff</div>
<div class="jumbotron specialjum">
<div class="over container body-content">
....page headers and other stuff
</div>
</div>
<p class="just container body-content">
... body text
</p>
</body>
/////////////////////////////////////////////////
body {
padding-top: 50px;
padding-bottom: 20px;
/*background:url("../Images/ps_neutral.png") repeat;*/
}
/* Set padding to keep content from hitting the edges */
.body-content {
padding-left: 15px;
padding-right: 15px;
}
.just {
text-align: justify;
}
.specialjum {
background: url('http://fc00.deviantart.net/fs70/i/2013/339/7/1/princess_kenny_korosu_by_theshadowstone-d6wu2zo.png') center;
color:#fff;
background-size: cover;
}
Edit:
Firefox + Chrome + IE10 results ===|================|===
Any Ideas on how to fix the layout? I haven't touch the Bootstrap CSS which I updated using Nuget.
Just to share my experience after creating an MVC web application in Visual Studio 2013 I could not get the jumbotron to stretch the width of the screen no matter what I did. I ultimately found that it was being blocked by a default **container body-content tag on the Views/Shared/_Layout.cshtml page. After removing the tag it displayed correctly. Hope that helps anyone with a similar situation to mine.
The solution was simple. This is how I div it:
<body>
<div class="navbar navbar-inverse navbar-fixed-top">.... Navigation stuff</div>
<div> <===================this Div wrapping jumbotron
<div class="jumbotron specialjum">
<div class="over container body-content">
....page headers and other stuff
</div>
</div>
<p class="just container body-content">
... body text
</p>
</div>
</body>
No changes to any part of the CSS. I don't know why it works, but it just works.
If you're just trying to remove the padding, then you'll want to put padding:0; in your .specialjum and make sure that the custom stylesheet is called after bootstrap. Otherwise add padding:0!important; if it needs to be called before. Also repeat this for margin-right: and add in width:100%; if it isn't stretching to the width of the page which I believe it should already.
See this jsFiddle
For anyone else that may end up here I have an alternative solution. I ran into this problem, but I just couldn't take my Jumbotron outside of it's container. What I did is just wrapped it in a <div class="row"></div>.
I'm still learning bootstrap so I don't know if this will cause any problems down the road, but for now it works pretty good.
In order to make the jumbotron full width, and without rounded corners, place it outside all .containers and instead add a .container within.
Another option in _Layout.cshtml (Where "Home" is the page you want to be full width):
#if (ViewData["Title"].Equals("Home"))
{
#RenderBody()
}
else
{
<div class="container container-main">
<main role="main">
#RenderBody()
</main>
</div>
}
Change width of .container to 100%:
container { width: 100% }

div being pushed down in Firefox

Please check out this website --> http://justicecup.radiantwebtools.com/
The section underneath the nav/logo/social-media area is further apart in Firefox as opposed to Chrome/Safari (the desired separation).
The issue seems to have to do with this part of the HTML:
<div class="header-container">...</div> <!--- Okay... --->
<div class="row content"> <!--- DevTools shows this the right underneath the header area...okay, thats correct --->
<div class="width-container">...</div> <!--- on Chrome/Safari it's good. On Firefox, this is pushed down further....why? --->
</div>
I have tried giving the header area some css to work against this, to no avail
.header-container { overflow:none;}
This screenshot shows the difference too --> http://screencast.com/t/CrF9HEaki
Thanks for your help.
I think the issue might have something to do with collapsing margins.
One fix for the issue, is to change the two rules below:
#template .content .story-primary {
margin-top: 28px;
}
#template .content .story {
margin-top: 62px;
}
to:
#template .content .story-primary {
padding-top: 28px;
}
#template .content .story {
padding-top: 62px;
}
Your page layout is quite complex and I think part of your problem stems from using .width-container in two unsuitable places. I've been fiddling with the css using the browser's inspect element, however when I change the styling in one it cascades to the other. I think a redesign of your page would be helpful. I would suggest enclosing the whole page content (excluding the background) in a div and applying the width-container styling to that.
<div id="body">
<div class="width-container">
<div id="templatewrapper"> ... </div>
<div id="templatefooter"> ... </div>
</div>
</div>
Next you should rename the width-container around the header stuff to something more appropriate.
<div id="page-header">
<div class="logo"> ... </div>
<div class="rwtmodule navigation-module meganav"> ... </div>
<div class="social-media"> ... </div>
</div>
After doing this you should replace the float:left; on the logo, navigation and social media to display:inline-block and get rid of the various margins. Then apply a padding or margin to the #page-header to push them down. The .logo and .social media will be in the wrong place but you can use position:relative and top:/*some value*/ to correct this.
After doing this, the site should look like the current firefox version in both firefox and chrome. You can then move the main body of the page up using relative positioning as you did with the logo and social media.
Remember to test this out in a safe location first!
Hope this helps.