CSS background-color Issue - html

I just have a header div into this div there is a navbar and after that there is some content i just gave that header div a background color but that background doesn't cover the hole screen width i just wanna that background cover the hole screen width but there is white space in the left,top and right
and here is the html code :
<!--Start header section-->
<div class="header">
<div class="container">
<div class="top-nav">
<h1>Apptastico</h1>
<ul>
<li class="active">Home</li>
<li>About</li>
<li>Work</li>
<li>Contact</li>
</ul>
</div>
<div class="content">
<img src="photos/iPhone.jpg" alt="">
<div class="web-design">
<h1>We design iOS apps</h1>
<h4>Ut In Nulla Enim. Phasellus Molestie Magna Non Est Bibendum Non Venenatis ut In Nulla Enim. Phasellus Molestie.</h4>
<p>Vivamus hendrerit arcu sed erat molestie vehicula. Sed auctor neque eu
tellus rhoncus ut eleifend nibh porttitor. Ut in nulla enim.
Phasellus molestie tempor. Suspendisse dictum feugiat.
</p>
<input type="submit" value="Request qoute">
</div>
</div>
</div>
</div>
<!--End header section-->
and here is css code
.header{
background-color: #4b5a65;
height: 505px;
overflow: hidden;
padding-top: 10px;
}
and that's the result which appear in the browser screen:

apply
body{
margin:auto;
}
See snippet below
.header{
background-color: #4b5a65;
height: 505px;
overflow: hidden;
padding-top: 10px;
}
body{
margin:auto;
}
<!--Start header section-->
<div class="header">
<div class="container">
<div class="top-nav">
<h1>Apptastico</h1>
<ul>
<li class="active">Home</li>
<li>About</li>
<li>Work</li>
<li>Contact</li>
</ul>
</div>
<div class="content">
<img src="photos/iPhone.jpg" alt="">
<div class="web-design">
<h1>We design iOS apps</h1>
<h4>Ut In Nulla Enim. Phasellus Molestie Magna Non Est Bibendum Non Venenatis ut In Nulla Enim. Phasellus Molestie.</h4>
<p>Vivamus hendrerit arcu sed erat molestie vehicula. Sed auctor neque eu
tellus rhoncus ut eleifend nibh porttitor. Ut in nulla enim.
Phasellus molestie tempor. Suspendisse dictum feugiat.
</p>
<input type="submit" value="Request qoute">
</div>
</div>
</div>
</div>
<!--End header section-->

Your background is not taking entire screen. You should mention background to take entire width.
background-size: cover;

<img src="photos/iPhone.jpg" alt="" />
<input type="submit" value="Request qoute" />
Usually when I put an image or input tag on the page, it comes with those slashes at the end. This may or may not make a difference.
Same with the alternative text for that image. Try putting any random word in there.

Related

How to structure a sidenav in HTML/Bootstrap 3?

I'm trying to understand how to structure divs/containers using the bootstrap grid system in order to get a proper responsive sidenav. I want my site to have a fixed sidenav and maybe eventually make it a pop-out sidenav when I get around to learning jquery. This is my HTML currently & the issue I am having currrently is I need to figure out a way to make it fixed, responsive and turn into a horizontal "hamburger" menu on ipad and mobile devices.
<div class="container-fluid">
<div class="navbar fixed-top">
<div class="row">
<div class="col-md-3 sidebar">
Sidebar Content
</div>
</div>
</div>
<div class="col-md-9 content">
Main Content
</div>
</div>
first thing I did was put everything in a container then I enclosed the nav into the navbar class which I don't know if that's the proper way to do it.
Also here is some CSS if you want to replicate what I have so far.
html, body, .container-fluid, .row {
height: 100%;
}
.sidebar {
background-color: #CCCCCC;
}
#media (min-width: 992px) {
.sidebar {
position: fixed;
top: 0;
left: 0;
bottom: 0;
z-index: 1000;
display: block;
background-color: #CCCCCC;
}
}
#media (min-width: 992px){
.content{
margin-left: 25%;
}
}
.row {
padding-top: 4rem;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet" />
<nav class="navbar fixed-top navbar-light bg-light">
<div class="container">
<a class="navbar-brand" href="#">Navbar</a>
</div>
</nav>
<div class="container-fluid">
<div class="row">
<div class="col-3 sidebar">
<h3>Sidebar</h3>
<ul>
<li>Lorem ipsum dolor sit amet, consectetuer adipiscing elit.</li>
<li>Aliquam tincidunt mauris eu risus.</li>
<li>Vestibulum auctor dapibus neque.</li>
</ul>
</div>
<div class="col-9 content">
<h3>Content</h3>
<p><strong>Pellentesque habitant morbi tristique</strong> senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. <em>Aenean ultricies mi vitae est.</em> Mauris placerat eleifend leo. Quisque sit amet est et sapien ullamcorper pharetra. Vestibulum erat wisi, condimentum sed, <code>commodo vitae</code>, ornare sit amet, wisi. Aenean fermentum, elit eget tincidunt condimentum, eros ipsum rutrum orci,
sagittis tempus lacus enim ac dui. Donec non enim in turpis pulvinar facilisis. Ut felis.</p>
</div>
</div>
</div>

How can I remove the space between two divs that are stacked vertically? [duplicate]

This question already has answers here:
Removing space between h1 and h2
(4 answers)
CSS margin-top of <h1> affects parent's margin
(5 answers)
setting the top margin of the h1 element in the header does not work as expected
(6 answers)
Closed 4 years ago.
This question is pretty simple. Take a look at the photo. I what the space between the footer and the div that is above it to be gone. The div and the footer must be flush. I tried every solution I can and I think I need help from someone more expierienced.
Below is the html and css code for what I am trying to do. See link for illustration
HTML and CSS
.content{
margin:0;
width: 100%;
/*padding-top:30px;*/
/*padding-left: 3px;*/
/*padding-right: 0px;*/
/*padding-bottom: 60px;*/
font-family: 'Lato', sans-serif;
}
#footer{
height:200px;
/*width:100%;*/
background:#1c1c1c;
text-align: center;
padding-top:69px;
padding-bottom: 69px;
}
.post_date{
padding:20px 0;
border-top: 1px solid #dbdbdb;
border-bottom: 1px solid #dbdbdb;
width:100%;
color:#dbdbdb;
}
.card{
width:100%;
height:379.6px;
/*background: red;*/
/*padding-left: 2px;*/
}
/*Card 6 properties*/
#c6{
background: #9b59b6;
}
#c6 h3{
color:white;
}
.b6,.s6{
color:white;
}
/**********/
img{
width:100%;
margin: 0px;
}
<section id="section-6" class="grid">
<div class="images img6">
<img src="images/pic12.jpg">
</div>
<div class="card" id="c6">
<div class="content">
<header>
<h3>Magna porta aliguam</h3>
</header>
<p class="post_date"> 3 days ago by <span class="s6">John Doe</span></p>
<p>
Nullam posuere erat vel placerat rutrum. Praesent ac consectetur dui, et congue quam. Donec aliquam lacinia condimentum. Integer porta massa sapien, commodo sodales diam suscipit vitae. Aliquam quis felis sed urna semper semper. Phasellus eu scelerisque mi. Vivamus aliquam nisl libero, sit amet scelerisque ligula laoreet vel.
</p>
<button class="btn b6"> Read More</button>
</div>
</div>
</section>
<footer id="footer">
<div id="social_media">
<ul>
<li><i class="fab fa-twitter"></i></li>
<li><i class="fab fa-facebook-f"></i></li>
<li><i class="fab fa-instagram"></i></li>
</ul>
</div>
<div class="copyright">
#Untitled Design. Templated: Images: Unsplash
</div>
</footer>
</main>
</body>
</html>
This is cause by the h3 margin in you header. Use the next snippet to remove that space.
header h3 {margin-top: 0px;}
Hope this helps :)
Add overflow:auto to your .content div.
Check this out: https://jsfiddle.net/vuyyxa04/
And check out collapsing margins while you're at it.
How about add margin-top: -23px to class card?
Or you can also add margin-bottom : -23 to img
.card{
width:100%;
height:379.6px;
margin-top: -23px;
}
Or
.images.img6 {
margin-bottom: -23px;
}
I hope this helps ^^
You can see it here https://jsfiddle.net/ajz9gj5n/
I found another way to solve this
https://jsfiddle.net/ajz9gj5n/1/
On the css i put
.images.img6 {
display: grid;
}
And i change the html from
<section id="section-6" class="grid">
<div class="images img6">
<img src="https://i.ytimg.com/vi/SfLV8hD7zX4/maxresdefault.jpg">
</div>
<div class="card" id="c6">
<div class="content">
<header>
<h3>Magna porta aliguam</h3>
</header>
<p class="post_date"> 3 days ago by <span class="s6">John Doe</span></p>
<p>
Nullam posuere erat vel placerat rutrum. Praesent ac consectetur dui, et congue quam. Donec aliquam lacinia condimentum. Integer porta massa sapien, commodo sodales diam suscipit vitae. Aliquam quis felis sed urna semper semper. Phasellus eu scelerisque mi. Vivamus aliquam nisl libero, sit amet scelerisque ligula laoreet vel.
</p>
<button class="btn b6"> Read More</button>
</div>
</div>
</section>
into this
<section id="section-6" class="grid">
<div class="images img6">
<img src="https://i.ytimg.com/vi/SfLV8hD7zX4/maxresdefault.jpg">
<div class="card" id="c6">
<div class="content">
<header>
<h3>Magna porta aliguam</h3>
</header>
<p class="post_date"> 3 days ago by <span class="s6">John Doe</span></p>
<p>
Nullam posuere erat vel placerat rutrum. Praesent ac consectetur dui, et congue quam. Donec aliquam lacinia condimentum. Integer porta massa sapien, commodo sodales diam suscipit vitae. Aliquam quis felis sed urna semper semper. Phasellus eu scelerisque mi. Vivamus aliquam nisl libero, sit amet scelerisque ligula laoreet vel.
</p>
<button class="btn b6"> Read More</button>
</div>
</div>
</div>
</section>
I put div "card" inside div "images img6"

Create multiple full screen divs

I'm trying to create a single page website, with multiple divs that are full screen, but I'm not being able to turn them full screen.
I'm Already using bootstrap to make the website responsive, and it's my first time doing that.
What I want to do is set a background video, then when I scroll down, the divs fitting the entire viewport
<!DOCTYPE html>
<html>
<head>
<link rel="icon" href="imagens/logo_icone.png">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="css/bootstrap.min.css">
<link rel="stylesheet" href="css/estilos.css">
<title>Museu do Barro Preto</title>
</head>
<body>
<div class="container-fluid">
<!--Video -->
<div class="row">
<div class="col-xs-12">
<video class="video_bg" autoplay muted loop>
<source src="video/prom.mp4" type="video/mp4">
A extensão do ficheiro não é suportada pelo seu browser
</video>
</div>
</div>
<!--/Video -->
<!--Barra de Navegação-->
<div class="row">
<header class="col-md-12">
<nav class="navbar navbar-inverse navbar-fixed-top">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">WebSiteName</a>
</div>
<div class="collapse navbar-collapse" id="myNavbar">
<ul class="nav navbar-nav navbar-right">
<li>Quem Somos</li>
<li>Onde Estamos</li>
<li>Educação</li>
<li>Video</li>
<li>Exposições</li>
</ul>
</div>
</div>
</nav>
</header>
</div>
<!--/Barra de Navegação-->
<div class="row pag1">
<article class="col-md-8">
<section>
<h1>Quem Somos</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque iaculis mattis odio, vitae aliquet orci porttitor quis. Morbi feugiat nulla sit amet felis rutrum, sed iaculis augue porta. Morbi semper et enim in ultricies. Morbi consectetur lorem sodales, maximus risus in, lacinia ex. Nulla metus risus, luctus in quam ut, maximus viverra sem. Nulla posuere condimentum hendrerit. Nulla pulvinar dictum magna non euismod. Quisque et elit nunc. Aenean non dignissim lectus. Ut et purus ac mauris luctus tempor.
Praesent elit quam, eleifend ac aliquet id, imperdiet a est. Nam gravida sed nunc at elementum. In hac habitasse platea dictumst. Aenean.</p>
</section>
</article>
<aside class="col-md-4">
<img src="http://www.dueceira.pt/trilhos/imgs/barro_preto_vnp2.jpg" alt="Peças Barro Preto">
</aside>
</div>
<div class="row">
<article>
<aside class="col-md-4">
<div id="mapa">
</div>
</aside>
<section class="col-md-8">
<h1>Onde Estamos</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque iaculis mattis odio, vitae aliquet orci porttitor quis. Morbi feugiat nulla sit amet felis rutrum, sed iaculis augue porta. Morbi semper et enim in ultricies. Morbi consectetur lorem sodales, maximus risus in, lacinia ex. Nulla metus risus, luctus in quam ut, maximus viverra sem. Nulla posuere condimentum hendrerit. Nulla pulvinar dictum magna non euismod. Quisque et elit nunc. Aenean non dignissim lectus. Ut et purus ac mauris luctus tempor.
Praesent elit quam, eleifend ac aliquet id, imperdiet a est. Nam gravida sed nunc at elementum. In hac habitasse platea dictumst. Aenean.</p>
</section>
</article>
</div>
<div class="row">
<div id="ilustracao">
<h1>SLIDESHOW DAS ILUSTRAÇÕES</h1>
</div>
</div>
<div id="video">
<div id="documentario">
<h1>Documentario</h1>
<video class="documentario" controls>
<source src="video/prom.mp4" type="video/mp4">
</video>
</div>
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js">
</script>
<script src="js/bootstrap.min.js"></script>
<script src="js/main.js"></script>
</body>
</html>
CSS
html,body {
height:100%;
margin:0;
}
html>body .pag1 {
height:auto;
}
.video_bg {
position: fixed;
top: 50%;
left: 50%;
min-width: 100%;
min-height: 100%;
width: auto;
height: auto;
z-index: -100;
transform: translate(-50%, -50%);
}
.borders {
border: 1px solid black;
}
.documentario {
width: 500px;
height: 500px;
}
.pag1 {
width: 100%;
height: 100%;
margin-top: 100%;
background-color: #fff;
overflow: hidden;
position: relative;
}
.pag1 img {
width: 400px;
height: 400px;
}
Try giving your div's a vh style. Such as
div {max-height:100vh;} // this will give your div a max height of 100 vertical height which is set to full screen size.
http://www.w3schools.com/cssref/css_units.asp
What you want is the vh unit, coupled with a fallback for browsers that don't support it. Unless it's a very big project (those scroll-y sites usually aren't) I'd ditch Bootstrap. It's pretty badly made, actually.
Last site we did that had to behave like that, we put each full-screen element in a li, sized the li using 100vh, falling back to regular px units set by javascript to match screen size, falling back to a set of common screen resolutions through conditional comments.
Sadly, using 100% created a lot of headaches with sizing child elements.
This is elaborate to set up, but if you do this once it will save you a lot of work later. It's also pretty much the only solid way to do this accessibly. (We test all our work through a group of users with assistive technology.)
So In essence:
<ol>
<li>
'Page' content here.
</li>
<li>
'Page'content here.
</li>
</ol>
ol {
display: block;
position: relative;
width: 100%; /* Caused no issues and is better supported */
height: auto;
float: left;
}
li {
display: block;
position: relative;
width: 100%;
height: 100vh;
float: left;
}
Look at Modernizr if you haven't already:
https://modernizr.com/
Also look at the various Javascript solutions for serving up compatible video formats, or you may find yourself showing a full-screen blank screen.
Oh, and insert obligatory warning here about video aspect ratio's not matching all screen aspect ratio's. ;-)

What's the best way to position a column next to the page content? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
Here what I have so far,
http://codepen.io/anon/pen/XXRYXY
What is the best way to position the green boxes (they represent advertisements) to the right side of the page content? In the code below I tried doing it with width:50%.
Should I plan out the width of my content and the width of the advertisements before even writing any code? I'm confused by how people plan out the creation of their webpage, because my screen width is 1920px and if I use that width as a model than users with smaller screens will view my webpage differently. What dimensions should I use when planning the measurements and positioning of my elements?
<body>
<div id="wrap">
<div id="head">
<div id="header" style="float:left;">
<p id="title">
Blog Title
</p>
<p id="description">Blog Description</p>
</div>
<div id="navbar" style="float:right;">
<ul style="list-style-type:none;">
<li>Start Here</li>
<li>Section 1</li>
<li>Section 2</li>
<li>Section 3</li>
<li>About</li>
</ul>
</div>
</div>
<div id="welcome-wrap" style="clear:both;">
<div id="first-time">
<h2>First time here?</h2>
<p style="margin:0;">Fusce ut finibus purus, quis convallis orci. Donec a est eget tellus euismod tincidunt non eu urna. Sed id gravida dui. Phasellus sed faucibus nisl. Proin blandit nisl eu lectus convallis.</p>
<br>
<br> If it's your first time here,
read this
</div>
<div id="topics">
<h2>TOPICS</h2>
<p><strong>Link Topic 1</strong>
<p><strong>Link Topic 2</strong>
<p><strong>Link Topic 3</strong>
</div>
</div>
<div id="inner" style="clear:both;">
<div id="content">
<div class="post">
<img width="300" height="200" src="contentimg.jpg">
<p>Mauris gravida diam id sem blandit, vitae vestibulum nunc interdum. Nulla congue felis eget tincidunt rhoncus. Nunc rutrum, massa a venenatis fermentum, nisi leo dictum sapien, ut venenatis quam neque sit amet quam. Nunc efficitur hendrerit
hendrerit. Sed sit amet tortor ex. Pellentesque dapibus porttitor massa eu iaculis. Curabitur varius vulputate sagittis. Aenean ac mauris eu justo lobortis accumsan a vitae est. Praesent imperdiet quam vitae porta lacinia.</p>
<a class="more-link" href="#" rel="nofollow">Continue Reading</a>
</div>
<div style="clear:both;"></div>
<div class="post">
<img width="300" height="200" src="contentimg.jpg">
<p>Nulla porttitor rhoncus justo in molestie. Aliquam sed vehicula mauris, quis egestas augue. In hac habitasse platea dictumst. Donec congue arcu mollis aliquet aliquam. Pellentesque purus dolor, commodo eget tincidunt nec, fringilla quis magna.
Nam suscipit cursus purus, in sodales tortor egestas suscipit. Proin ut augue sit amet nulla laoreet maximus id eu nibh. Pellentesque dapibus finibus egestas.</p>
<a class="more-link" href="#" rel="nofollow">Continue Reading</a>
</div>
<div style="clear:both;"></div>
<div class="post">
<img width="300" height="200" src="contentimg.jpg">
<p>Fusce ut finibus purus, quis convallis orci. Donec a est eget tellus euismod tincidunt non eu urna. Sed id gravida dui. Phasellus sed faucibus nisl. Proin blandit nisl eu lectus convallis, vel ultricies risus varius. Morbi id nibh enim. Suspendisse
potenti. Nulla facilisi. Quisque congue lacinia dapibus.</p>
<a class="more-link" href="#" rel="nofollow">Continue Reading</a>
</div>
</div>
<div id="sidebar" style="float:right;">
<div>
<p>
<img src="https://encrypted-tbn1.gstatic.com/images?q=tbn:ANd9GcS1uD8Fj5M9sS4Lo1OrKIycgx2gMDnEE7zHru3j--pDFlwqujXiKA">
</p>
<p>
<img src="https://encrypted-tbn1.gstatic.com/images?q=tbn:ANd9GcS1uD8Fj5M9sS4Lo1OrKIycgx2gMDnEE7zHru3j--pDFlwqujXiKA">
</p>
<p>
<img src="https://encrypted-tbn1.gstatic.com/images?q=tbn:ANd9GcS1uD8Fj5M9sS4Lo1OrKIycgx2gMDnEE7zHru3j--pDFlwqujXiKA">
</p>
<p>
<img src="https://encrypted-tbn1.gstatic.com/images?q=tbn:ANd9GcS1uD8Fj5M9sS4Lo1OrKIycgx2gMDnEE7zHru3j--pDFlwqujXiKAg">
</p>
</div>
</div>
CSS:
body{
padding:0;
margin:0;
}
#wrap{
margin-left:500px;
margin-right:500px;
max-height:5000px;
}
/*head*/
#head{
min-height:135px;
width:960px;
margin-top:50px;
}
#title a{
font-size:2em;
text-decoration:none;
color:black;
}
#description{
font-size:0.9em;
}
#header p{
margin:0 !important;
}
#navbar ul li{
float:left;
padding-left:1.5em;
margin-left:0;
}
#navbar ul li a{
color:black;
text-decoration:none;
font-size:1.2em;
margin-left;0;
}
/*sub head*/
#welcome-wrap{
width:100%;
height:500px;
}
#first-time{
float:left;
width:450px;
padding-right:150px;
}
#topics{
float:left;
text-align:center;
background-color:green;
width:300px;
height:280px;
}
/*content*/
#inner{
width:50%;
float:left;
}
#sidebar{
float:right;
width:50%;
}
.post a{
float:left;
}
Ok, after putting your code in an IDE(Notepad++) I have figured out your problem.
First off you have to close off your main div #wrap.
Second off the property value margin-right: which was given to #wrap is completely unnecessary due to the fact that it is not serving any visual purpose and also preventing your (advertisements) from being floated to the right side of your page.
and if you want to move the sidebar up or down just add to their margin-top or margin-bottom respectively.

jQuery Mobile: header does not show correctly in calling page

Here is my HTML code
<div data-role="page" id="main-body">
<div data-role="header">
<!--<img src="img/back.png" width="30" height="30" class="ui-btn-left" />-->
<img src="img/share.png" width="30" height="30" class="ui-btn-right" />
<h1>Hello world</h1>
</div>
<ul data-role="listview" data-inset="true">
<li>Acura</li>
<li>Audi</li>
<li>BMW</li>
<li>Cadillac</li>
<li>Ferrari</li>
</ul>
</div>
<div data-role="page" id="asked-question-body">
<div data-role="header">
<img src="img/back.png" width="30" height="30" class="ui-btn-left" />
</div>
<div data-role="main" class="ui-content">
<div class="ui-body ui-body-a ui-corner-all">
<h3>Heading</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse accumsan blandit fermentum. Pellentesque cursus mauris purus, auctor commodo mi ullamcorper nec. Donec semper mattis eros, nec condimentum ante sollicitudin quis. Etiam orci sem, porttitor ut tellus nec, blandit posuere urna. Proin a arcu non lacus pretium faucibus. Aliquam sed est porttitor, ullamcorper urna nec, vehicula lorem. Cras porttitor est lorem, non venenatis diam convallis congue.</p>
</div>
</div>
</div>
it shows id="main-body" header perfectly but id="asked-question-body" doesn't show its header correctly. I want to show its header perfectly as main-body page.
main-body screenshot is
and asked-question-body
Thanks in advance.
Add in asked-question-body page
<div data-role="header">
<h1></h1>
</div>
CSS
<style>
.ui-icon-btnback:after {
background: url(back.png) 50% 50% no-repeat;
}
</style>