I have started developing my first website. I have run into an issue though - I can't figure out how to make a "Banner Image"!
Here is an example of what I'm trying to achieve:
Since I am a beginner in CSS, how would I make a simple version of this?
There are two ways using which you can create a banner image, the easy way and the not-so-difficult way.
The Easy Way:
Create a banner image using an image editing software like Photoshop and then use that image as a background-image on a <div>. Like this:
#bannerimage {
width: 100%;
background-image: url(http://s30.postimg.org/x0ne0p5wx/bootsrap.png);
height: 405px;
background-color: purple;
background-position: center;
}
<div id="bannerimage"></div>
The Not-So-Difficult Way:
You will need to convert the banner design into HTML and style it using CSS. For example, let's take into account that purple bootstrap banner. It has a large purple background and all the text is added on it and then styled using CSS. You can do that like this:
#header {
background: #664c8f;
height: auto;
padding: 100px 100px
}
h1 {
color: white;
font-family: Arial;
text-align: center;
}
a#download {
display: block;
text-align: center;
width: 150px;
margin: 0px auto;
padding: 20px;
color: white;
text-transform: uppercase;
font-family: Arial;
border: 1px solid #fff;
text-decoration: none;
border-radius: 10px;
}
<div id="header">
<h1>Bootstrap is the most popular HTML, CSS, and JS framework for developing responsive, mobile first projects on the web.</h1>Download
</div>
I hope this helps.
#bannerimage {
width: 100%;
background-image: url(http://s30.postimg.org/x0ne0p5wx/bootsrap.png);
height: 405px;
background-color: purple;
background-position: center;
}
<div id="bannerimage"></div>
Related
I'm trying to contain an image inside the first div of this page and it's outside of it for some reason. All the assets are in a flexbox. It works completely fine when I put text inside that div but not an image.
I've circled in red which image and div I'm talking about. The code snippet won't show you what I'm talking about since it isn't the full code.
Here is the github repository if someone needs the full code: github.com/hiashley/Ashley-Yu-React-Portfolio
.landing {
height: 100vh;
display: flex;
align-items: center;
justify-content: center;
}
.introWrapper {
width: 1000px;
}
.intro1 {
font-size: 25px;
text-align: center;
font-family: 'Yapari';
align-items: center;
justify-content: center;
margin-top: 23px;
}
.intro2 {
font-size: 25px;
text-align: center;
font-family: 'Yapari';
/* font-weight: 72; */
margin-top: 50px;
}
#introCircle {
border: 2px solid black;
border-radius: 50%;
width: 230px;
height: 70px;
margin: auto;
}
.icons {
border: 2px solid black;
height: 50px;
}
.icon1 {
width: 30px;
}
<div id='landing' className={styles.landing}>
<div className={styles.introWrapper}>
<div className={styles.icons}>
<img src={icon1} className={styles.icon1}/>
</div>
<div id={styles.introCircle}>
<h1 className={styles.intro1}>HELLO I'M</h1>
</div>
<LastName />
<h1 className={styles.intro2}>A FULL STACK DEVELOPER</h1>
</div>
</div>
As I checked the code, You have added Position "Absolute" to the "img" tag, That's why Image is going outside to your div. You must need to add class and then add CSS to image tag.
View Screenshot
Add style to className rather than add style to html tags directly.
Tag style is globally, module className style is locally.
I am trying to replicate the behaviour of a piece of HTML and CSS content that appears on the website i have provided a link to below. The website in question is www.air-it.co.uk.
I have included below a mockup image, which indicates the layout that i want to achieve.
I do not know how else other than to link to the working version on the website below to visualise this for users reading this question, because i do not know how to solve the problem i am trying to address with this question using HTML and CSS.
The example of this can be seen roughly 1/3 of the way down the following page.
www.air-it.co.uk
Essentially, it appears to be be positioning one div on the left over another div on the right within a container. It appears to be leveraging a 'card content' element which is placed over another div containing a background image.
I could possibly do this at one screen size using absolute positioning, i think. But i need it to behave responsively in a similar way (or the same way) as the example above?
I am aware that the above example uses Foundation. But my question would be is there an inbuilt way to do this using Bootstrap?
I would imagine the alternative here is to customise CSS for different media queries in order to do this, which unfortunately i don't know how to do.
Please do not simply close this question again if you would like to take umbrage with my syntax or question structure. Kindly post your feedback or criticism in a comment which will allow me to revise this question as opposed to simply closing the question with no additional clues or feedback as to why you have chosen to do so.
Thank you.
maybe this can help, try to open in full view
body {
font-family: Roboto;
margin: 0;
}
.overlap-section {
min-height: 450px;
background-color: #fff;
display: inline-block;
float: left;
width: 45%;
border: 1px solid #ff5722;
padding: 50px;
position: absolute;
z-index: 99;
top: 50%;
transform: translateY(-50%);
left: 5%;
}
.main-box {
background-color: lightgray;
height: 100%;
width: 75%;
float: right;
position: relative;
}
.main-section {
height: 100vh;
position: relative;
}
.text-wrapper {
display: inline-block;
position: absolute;
top: 50%;
right: 26%;
transform: translate(50%, -50%);
}
.text-wrapper h2 {
display: inline-flex;
margin: 0;
text-transform: uppercase;
line-height: 42px;
color: #fff;
font-weight: bold;
}
.overlap-section h3 {
text-transform: uppercase;
font-weight: bold;
font-size: 30px;
padding-bottom: 25px;
}
.overlap-section label {
font-size: 25px;
display: block;
}
.overlap-section span {
font-size: 16px;
padding: 18px 0;
display: block;
}
.button-wrapper {
margin: 0 auto;
display: table;
padding-top: 52px;
}
.button-wrapper .custom-btn {
color: #fff;
background-color: #ff5722;
padding: 14px 35px;
border: 0;
font-size: 19px;
}
<div class="main-section">
<div class="overlap-section">
<h3>Header text is here</h3>
<label>More header text here</label>
<span>List item</span>
<div class="button-wrapper">
<button class="btn-default custom-btn" type="button">Call to action here</button>
</div>
</div>
<div class="main-box">
<div class="text-wrapper">
<h2>This Grey Element</h2><br>
<h2>Will contain an image</h2>
</div>
</div>
</div>
I have a logo laid out in a box at the top of my page using the following style elements:
div.imgBox {
margin: 0%;
padding: 1%;
border: 0px;
background-color: #00A7FF;
}
div.imgBox img {
display: inline;
margin: 0px;
padding: 1%;
border: 0px solid #00A7FF;
}
Which does an okay job of allowing me to position the image how I want it in an area at the top of my page (along with some other elements such as nav items). I'd like the whole thing to display without a border so it fills up the whole of the top of the browser window. I can achieve this by adding:
body {
margin: 0px;
padding: 0px;}
But when I do this it causes the image in the box to be clipped. I'm sizing the image in the html:
<img alt="Logo" src="images/Logo.gif" style="width:15%; height:15%">
The image only clips when I add the body margin and padding, my question is: how do I get the elements at the top of the page to display so they take up the whole browser window width and go right to the top without the image clipping?
Here is the whole source, as requested:
div.imgBox {
margin: 0%;
padding: 1%;
border: 0px;
background-color: #00A7FF;
}
div.imgBox img {
display: inline;
margin: 0px;
padding: 1%;
border: 0px solid #00A7FF;
}
.hdrBox {
display: inline;
float: left;
margin: 0px;
width: 100%;
background-color: #00A7FF;
}
a:link {
color: #FFFFFF;
background-color: transparent;
text-decoration: none;
color: #FFFFFF;
background-color: transparent;
text-decoration: none;
}
a:visited {
color: #FFFFFF;
background-color: transparent;
text-decoration: none;
}
a:hover {
color: #FFFFFF;
background-color: transparent;
text-decoration: none;
}
a:active {
color: #FFFFFF;
background-color: transparent;
text-decoration: none;
}
navBar{
float: right;
right: 5vw;
top: 10vw;
list-style-type: none;
margin: 0;
padding: 0;
}
navElement{
font-family: "Arial", Helvetica, sans-serif;
font-size: 2vw;
color: #FFFFFF;
float: right;
display: block;
width: 10vw;
border: 0.25vw solid #FFFFFF;
padding-left: 1vw;
padding-bottom: 0.25vw;
padding-top: 0.25vw;
margin: 0.25vw;
}
That's in style tags in the head section of the HTML and then some fairly simple (until I get the style sorted!) HTML in the body:
<body>
<div class="imgBox">
<img alt="Logo" src="images/Logo.gif" style="width:15%; height:15%">
<navBar>
<navElement>Contact</navElement>
<navElement>Examples</navElement>
<navElement>Services</navElement>
<navElement>Profile</navElement>
<navElement>Home</navElement>
</navBar>
</div>
<div class="hdrBox">
</div>
I plan to move the style elements to a separate CSS once I've got it sorted. This works fine but when I add the aforementioned body margin padding elements to the start of this it clips the image.
This is how it displays in Firefox. Note the clipping on the text at the bottom and left of the logo, minor admittedly but still annoying the heck out of me!
I must apologise, I think it must have been my twin screen setup! It displays perfectly on my laptop when I run it in single screen mode. MASSIVE facepalm! When I reconnect the second monitor and refresh the clipping is still evident (although apparently slightly less so since a reboot so maybe Dave had something with the cache issue?) Thanks to all who've contributed and SIGNIFICANT apologies for having wasted your time on this! Really should have stripped it down to basics and tried to remove all variables before posting, I've overcomplicated the issue (gonna claim noob numpty for my lack of experience in website building as the cause).
Anyway, big thank you for being my rubber ducks (Coding Horror - Rubber Duck Problem Solving)
Tempted to give myslef a downvote for this...
I have been trying to align two elements, a h2 and a div side by side without having one of them colapse when the window changes to a smaller size. I've searched the web a bit but found nothing similar that would help and my solutions just wouldn't work so I though here there would be someone able to help me.
So I want it to be displayed like this at all times:
https://imagizer.imageshack.us/v2/912x135q90/631/ZYR7sc.png (Can't post images sorry!)
But when window size changes dispite the fact the div should adapt at some point it just breaks to next line:
https://imagizer.imageshack.us/v2/730x144q90/912/yRBpkc.png
Here is my code on this one:
HTML
<div id='pagetitle'>
<h2 id='subtitle'>Weapons</h2>
<div id='hline'></div>
</div>
CSS
#pagetitle { /* This div is for centering both of the elements. */
width: 90%;
margin: 0 auto;
display: block;
}
#subtitle {
display: inline-block;
color: #72c9b9;
font-size: 30px;
font-weight: 300;
text-align: center;
}
#hline {
display: inline-block;
background-color: #72c9b9;
width: 70%;
height: 1px;
position: relative;
bottom: 4px;
margin-left: 20px;
}
So this is it guys, any sugestions? Thanks in advance.
cs.almeida
Here's a way how to do it:
demo
<div id='pagetitle'>
<h2 id='subtitle'><span>Weapons</span></h2>
</div>
#pagetitle {
width: 90%;
margin: 0 auto;
display: block;
}
#subtitle {
border-bottom: #72c9b9 solid 2px;
height: 18px;
display: block;
color: #72c9b9;
font-size: 30px;
font-weight: 300;
}
#subtitle > span {
background-color: white;
padding: 10px 20px;
}
I have started styling for my new websites navigation bar however my background color isn't working for it or any other Divs that I use, Div IDs are not being picked up either. My whole style seems to be messing up and this has never happened before.
Here is the code:
<div class="bar">
<img src="/img/NavBar/Logo.png">
Link 1
Link 2
Link 3
Link 4
Link 5
</div>
CSS:
body{
margin: 0;
padding: 0;
font-family: 'PT Sans', sans-serif;
font-size: 14px;
background:url("/img/Global/Background.jpg");
background-repeat: no-repeat;
background-size: cover;
background-attachment: fixed;
}
//*NAV BAR*//
.bar {
background-color: #0F0F0F;
width: 100%;
height: 70px;
opacity: 0.7;
filter: alpha(opacity=70); /* For IE8 and earlier */
}
.bar a {
padding-left: 40px;
padding-right: 40px;
text-decoration: none;
font-size: 20px;
color: #FFFFFF;
float: right;
margin-top: 20px;
}
.bar img {
margin-top: 10px;
margin-left: 20px;
}
The CSS is connected because my background image is showing, however background colours are not showing. I have tried different colours to make sure that it's not just poor contrast between the background image and the colour itself as well.
Anyone have any ideas as to what is wrong here?
The culprit is the //*NAV BAR*// comment. // isn't valid CSS comment syntax. It makes your whole CSS file invalid. Replace it with /*NAV BAR*/