I tried expressing my problem earlier in another thread, but the only way that could fix it, caused the website to not be compliant with different size devices. The method I have now tried to use is the vertical center method stated in this topic.
vertical-align with Bootstrap 3
What I'm wanting to happen is to have a full page background along with a horizontally / vertically aligned div tag that contains my name and occupation. But instead what's happened is that it aligns the text to the middle of the page, but then it just doesn't align it vertically.
<div class="container-fluid text-center">
<header role="banner" id="banner" class="vcenter">
<h1>name</h1>
<h2>occupation</h2>
<h3>location</h3>
</header>
</div>
CSS
header {
/*position:absolute;
top: 50%;
left: 50%;
transform: translateX(-50%) translateY(-50%); */
font-family: Roboto-thin ;
padding: 0px;
border-style: none;
color:#ffffff ;
}
header h1 {
font-family:;
font-size: 8rem; /* =28px */
letter-spacing: 0.05em;
padding: 0px ;
margin-top: 0px;
margin-bottom: 13px;
}
header h2 {
font-family: ;
font-size: 5rem;
padding: 0px;
margin: 0px;
}
header h3 {
font-family: ;
font-size: 3rem;
}
.container-fluid {
background-image: url(../../images/intro.jpg);
background-repeat:no-repeat;
background-attachment: scroll;
background-position: center center;
background-repeat: none;
-webkit-background-size: cover;
-moz-background-size: cover;
background-size: cover;
-o-background-size: cover;
margin:0px;
padding:0px;
height:100%;
}
.vcenter {
display: inline-block;
vertical-align: middle;
float: none;
}
The old method I used can be found in the header tag commented out. This method works fine for some browsers, but it seems that most browsers don't support the transform function.
Thanks in advance.
Bootstrap typically uses percentages for cross-platform/cross-browser capabilities. Maybe you could try adding something like this to your css file (alongside your .vcenter class):
.vcenter::before {
content:'';
display:inline-block;
height: 100%;
vertical-align:middle;
width:0px;
}
This will retrieve the height of the screen based on percentages and format the text vertically before it is displayed, which in theory, should work on all devices and browsers(for the most part). In IE8 you've got to use :before instead of ::before and have a !DOCTYPE declared. Hope this helps!
Related
I'm new to html/css, and I want to using only HTML/CSS to make navbar always on top when scroll down becoming transparents. it's possible? right now it's make me crazy I can't make background image under my navbar. where should I change the CSS part?
here is what I expect to become
[a link] https://frankyeah.github.io/Front-Enter/index.html
What I have done is the following
HTML:
<nav>
<div>
<img src="./image/FE_logo-4.png">
Logo
</div>
<div class="navlist">
explore
Skill
login
</div>
<div>
<a href="" class="search"><img src="./image/FE_search_green.png">
</a>
</div>
</nav>
<main>
<div class="mainview"></div>
<div class="mainview2"></div>
<div></div>
<div></div>
<div></div>
</main>
CSS:
<style>
nav{
display: flex;
justify-content: space-between;
flex-flow:row nowrap;
position: fixed;
width:100%;
background-color: white;
opacity:0.7;
z-index:999 ;
margin: 0 auto;
padding: 0;
}
.logo>img{
display: flex;
flex-flow:row nowrap;
width:50%;
margin-top:5%;
margin-left:20%;
}
.navlist{
display: flex;
flex-flow:row nowrap;
width:40%;
justify-content: space-evenly;
margin-top:2.5%;
margin-left:40%;
font-family:"arial";
}
a:hover{
color: #66FFFF;
}
div a{
text-decoration: none;
color:#AAAAAA;
}
.search>img {
display: flex;
flex-flow:row nowrap;
margin:30px 50px;
width:20%;
}
.mainview{
overflow: hidden;
background-image:url("../image/key-visual.jpg");
background-repeat:no-repeat;
background-attachment:scroll;
background-size: cover;
widows: 100%;
height: 100%;
padding-top: 50%;
}
.mainview2{
background-image:url("../image/second-img.jpg");
background-attachment:scroll;
background-position:top left;
background-repeat:no-repeat;
background-size: cover;
widows: 100%;
height: 100%;
padding-top: 50%;
margin: 0 0;
}
</style>
I expect the background image will under my navbar and when scrolling down navbar will be transparents, but something going wrong.
You cannot detect if scrolling happens with only css. You must use JavaScript/jQuery.
In your website example though, it looks like the header is always transparent, and it is just resting above a white div at the top of the page.
Try adding a div to the top of your page and setting its height to the same height of the navbar, similar to the website.
I think you need to learn about the a parallax scrolling effect. You can learn it from this link : https://www.w3schools.com/howto/howto_css_parallax.asp
<style>
.parallax {
/* The image used */
background-image: url("img_parallax.jpg");
/* Set a specific height */
height: 500px;
/* Create the parallax scrolling effect */
background-attachment: fixed;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
}
</style>
<!-- Container element -->
<div class="parallax"></div>
It is possible to change the nav bar transparency based on the scroll position using css and javascript. I have modified your code and you can see it in this link : https://jsfiddle.net/SyamKumarD/r37n6cp8/20/
Hope this will help
Newbie here hacking away at this little project:
http://development.puretapecult.divshot.io/
And my question is, how do I automatically resize the .pngs in the center of the screen when the browser size collapses, or when it is viewed on a mobile browser?
Do I have to use #media queries for mutliple viewing sizes, and create multiple classes for each png?
Any help appreciated.
CSS classes that modify the images:
.spinner-outer {
display: block;
width: 327px;
height: 327px;
position: absolute;
left: 50%;
margin-left: -163px;
border-radius: 50%;
background: url(spinner-outer.png) center center no-repeat #32302e;
}
.spinner-center {
height: 200px;
width: 200px;
position: absolute;
background: url(spinner-center.png) center center no-repeat;
border-radius: 50%;
left: 50%;
top: 50%;
margin: -99px;
pointer-events: none;
}
.play-sprite {
position: absolute;
top: 50%;
left: 50%;
margin: -35px 0 0 -35px;
background: url(play-sprite.png) 0px 0px no-repeat;
height: 70px;
width: 70px;
}
I would use media queries to change the height and width of the divs. Note that you do not need to create multiple classes for different sizes. Just use multiple media queries like this:
#media (max-width: 768px) {
.spinner-outer {
width: 200px;
height: 200px;
}
}
You'll also need to specify that you want your background image to fit the size of the div or it won't change sizes when the div does. Use the CSS3 property background-size as long as you're comfortable not supporting old browsers.
.spinner-outer {
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
More info on background-size and some alternative techniques if you want to support older browsers: https://css-tricks.com/perfect-full-page-background-image/.
Try somthing like this.
HTML:
<div class="image-wrapper">// Div will always re-size with page.
<img src="[src]" />
</div>
CSS:
.image-wrapper{
max-width:90%;
height:auto !important;
position: relative;
display:block;
margin:0 auto;
}
.image-wrapper img{
max-width:100% !important;
height:auto !important;
display:block;
}
Or you can use bootstrap and add a class to image like so.
.img-responsive
Makes an image responsive (will scale nicely to the parent element)
<img src="[src]" class="img-responsive" alt="[Alt]">
http://codedifferently.com/crest.html is the page that I am working on.
This is my CSS file:
#charset "UTF-8";
/* CSS Document */
/* Move down content because we have a fixed navbar that is 50px tall */
body {
padding-top: 0px;
padding-bottom: 0px;
margin: 0px;
}
div.jumbotron {
background-image: url('img/chicago2.jpg');
background-color: #CCC;
background-size: cover;
height: 450px;
background-repeat: no-repeat;
background-position: center center;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
border: none;
margin-top: 0px;
padding: 0px;
}
div.navbar navbar-default navbar-static-top" role="navigation {
border: 0px;
}
/* Center align the text within the three columns below the carousel */
.marketing .col-lg-4 {
margin-bottom: 0px;
text-align: center;
}
.marketing h2 {
font-weight: normal;
}
.marketing .col-lg-4 p {
margin-right: 0px;
margin-left: 0px;
}
.featurette-divider {
margin: 80px 0; /* Space out the Bootstrap <hr> more */
}
/* Thin out the marketing headings */
.featurette-heading {
font-weight: 300;
line-height: 1;
letter-spacing: -1px;
}
/* RESPONSIVE CSS
-------------------------------------------------- */
#media (min-width: 768px) {
/* Navbar positioning foo */
.navbar-wrapper {
margin-top: 0px;
}
.navbar-wrapper .container {
padding-right: 15px;
padding-left: 15px;
}
.navbar-wrapper .navbar {
padding-right: 0;
padding-left: 0;
}
/* The navbar becomes detached from the top, so we round the corners */
.navbar-wrapper .navbar {
border-radius: 4px;
}
/* Bump up size of carousel content */
.carousel-caption p {
margin-bottom: 20px;
font-size: 21px;
line-height: 1.4;
}
.featurette-heading {
font-size: 50px;
}
}
#media (min-width: 992px) {
.featurette-heading {
margin-top: 120px;
}
}
I am using the Jumbotron preset on the Bootstrap framework.
How do I get rid of the borders on the background image and what should I do to add margins/padding on the featurettes to take them away from the edge? I've put my jumbotron.css file at the top of my source code but it does not have any effect. Is it because of the bootstrap css files interfering?
I dont see borders on your example, however, I see a padding which comes in bootstrap with the Jumbotron, so if you mean borders by the space you cant work in: Jumbotron uses a padding of 30px by standard. You can overwrite that with:
.jumbotron {padding: 0px;}
However, your css on that page is different on how you posted it. Your CSS given on your page as Jumbotron class is as followed.
div.jumbotron {
background-image: url('img/chicago2.jpg');
background-color: #3FF;
background-size: cover;
height: 500px;
background-repeat: no-repeat;
background-position: center center;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
border: none;
}
So either you havent updated your stylesheet to what is up there, or you made a typo somewhere.
So i checked of in the image the padding 30px, plus the padding top and bottom from your media query, and it works completely fine. Also, because you have added a container to your text, you are bound by the size of the container too. Remind that, if you think it wont outline to the left side of your screen.
Also it has some media queries on certain sizes, you might have to alter those too.\
-- edit --
Dont wanna talk out of line btw, but youre getting a internal server error on your bootstrap.min.js and your viewport work arround for IE-10 .
Last but not least. you are calling the bootstrap min file prior to the jquery file, which is a no-no, bootstrap wont function if jquery isn't called before the bootstrap file. Remove the upper bootstrap in your head, else it will causes errors, which it does btw as first error, since you also put bootstrap in yoru scripts below the footer, you re good to go
I am attempting to make the header/menu bar on this website static (fixed) so that it is always present at the top of the screen, and a particularly long website scrolls 'behind' it. I have accomplished this before on fixed width websites, but this website is fluid width and I have not been able to accomplish this yet without breaking the header.
Could someone potentially tell me where/what I need to edit in my CSS? I believe I need to add a position:fixed; element somewhere, perhaps in this section, but it doesn't seem to accomplish my goal in the same way as on a fixed width website.
.art-header
{
margin:0 auto;
background-repeat: no-repeat;
height: 170px;
position:relative;
background-image: url('images/header.jpg');
background-position: center top;
}
.custom-responsive .art-header
{
background-image: url('images/header.jpg');
background-position: center top;
}
.default-responsive .art-header,
.default-responsive #art-header-bg
{
background-image: url('images/header.jpg');
background-position: center center;
background-size: cover;
}
.art-header-inner{
position: relative;
min-width: 840px;
max-width: 1920px;
width: 50%;
z-index: auto !important;
margin: 0 auto;
}
try this, merge your .art-header & .art-nav inside a div, and class fixed to it like this
<div class="fixed">
//div .art-header & nav .art-nav here
</div>
then add the css for fixed
.fixed {
position: fixed;
z-index: 100;
}
and make some margin for .art-sheet
margin-top: 241px; /*the height of the fixed div*/
here's the JSFIDDLE
I have an image background on my website:
body {
background-image:url('tlo.jpg');
background-color:#000000;
background-repeat:no-repeat;
background-attachment:fixed;
background-position: center center;
background-size: auto auto;
(...)
}
There are not any problems on PC, but mobile devices with vertical screen renders background not exactly in the same way: it seems that mobile browsers fit the background horizontally, so vertically it covers only small piece of website. I've tried to fix it by using different values for background-size attribute, but it didn't work.
My CSS + HTML:
body {
background-image:url('tlo.jpg');
background-color:#000000;
background-repeat:no-repeat;
background-attachment:fixed;
background-position: center center;
background-size: auto auto;
margin-left: 0;
margin-right: 0;
}
#overall {
margin-left: 0;
margin-right: 0;
width: 100%;
height: 100%;
}
#logo {
position:absolute;
left:0;
top:0;
}
#content {
margin: auto;
position: absolute;
top: 0; left: 0; bottom: 0; right: 0;
width: 100%;
height: 300px;
background-color:rgba(255,255,255,0.5);
text-align: center;
}
and
<body>
<div id="overall">
<div id="logo"><img src="logo.png" width="654" height="150"></div>
<div id="content"><img src="cont.png" border="0"></div>
</div>
</body>
This is the solution that I came up with. It works perfect on both landscape and portrait screens.
background: url(bg.jpg) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
I would suggest you to load two different images. One for desktops and another for mobile devices. You can use the less sized image for the mobile devices which can in turn reduce your loading time for mobile devices. You can use the CSS Media Queries to do so. Here is a tutorial for the CSS Media Queries.
CSS Media Queries & Using Available Space