Displaying image from within CSS file - html

I am working on an application and am attempting to show the header image using #URL.Content from within the CSS sheet, like so
.jumbotron .header-image {
min-width:1024px;
min-height:267px;
background-image: url('#Url.Content("~/Content/images/header.png")');
the image is there but all I get is a square box where the header should be. I am displaying it simply enough
<div class="jumbotron">
<div class="jumbotron header-image"></div>
</div>
Where am I going wrong?
EDIT
#Jesse this is all of it:
.jumbotron {
text-align: center;
background-color: transparent;
background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#f5f5f5), color-stop(100%,#e5e5e5)); /* Chrome,Safari4+ */
background-image: -webkit-linear-gradient(top, #f5f5f5 0%,#e5e5e5 100%); /* Chrome 10+,Safari 5.1+ */
}
.jumbotron .btn {
font-size: 21px;
padding: 14px 24px;
}
.jumbotron .header-image {
min-width:1024px;
min-height:267px;
background-image: url('#Url.Content("~/Content/images/header.png")');
}
<div class="jumbotron">
<div class="jumbotron header-image"></div>
</div>
I cannot figure out why this isnt working, it looks correct

I believe you are getting a conflict with your two background style declarations, one in jumbotron and the other with .header-image. Is there a reason you want to use:
<div class="jumbotron">
<div class="jumbotron header-image"></div>
</div>
instead of just:
<div class="jumbotron">
<div class="header-image"></div>
</div>

I have some following suggestions. See if it can help you. Have step by step approach.
Firstly, Instead of the code <div class="jumbotron header-image"> you can simply use it as <div class="header-image">. Because, with the Combination you can still get the desired effect. [I know, you are using class jumbotron to have transparency]
Second, make sure as what is the path that your code assumes/renders. As you are using #Url.Content("~/, it gives you, your application root. That means if you try to construct the URL as http://YOUR_APPROOT/Content/images/header.png [Please change your APPROOT appropriately, before checking] and put in the address bar of the browser, you should see the Image. If you are not, then there should be some issue about the Path. Just a guess.. Is the folder Content, in capital letter or small? Just check.
Third, somewhat similar posts from SO may be of some use to you. Just Check:
Is there a benefit to using #Url.Content("~")
slash(/) vs tilde slash (~/) in style sheet path in asp.net [Refer the Accepted Answer of this post]
Hope this will help you solve your issue. Good Luck

Related

How to make a background in a container and put the text in the middle of the photo? HTML/ CSS

I am learning HTML/ CSS and JS. I am making my first website and I have a problem. How can I change the background in the container under the pictures, to my color. On the internet I only find bg-secondary etc and I need for example #82b5cf.
I also have a question, I want to put the text in the middle of the picture, now it is under the photo and I can't do anything with it, for a test I changed the font and there is no reaction. Thank you very much for your help :)
main {
.aboutus-card-title {
font-size: 30px;
}
}
<main>
<section id="UAV" class="...."> //#82b5cf
<div class="container ">
<div class="row gx-4 ">
<div class="col-sm ">
<img class="uav-photo" src="img/introduction_1.jpg" alt="An orange four-engine drone hovers in the clear blue sky.">
<p class="aboutus-card-title">Introduction</p>
</div>
<div class="col-sm">
<img class="uav-photo" src="img/UAV_features_2.jpg" alt="An orange four-engine drone hovers in the clear blue sky.">
<p class="aboutus-card-title">Elements</p>
</div>
</div>
</div>
</section>
</main>
For your first question, it sounds like you're wanting a fallback color behind your image. Here's an example how to do this from: https://css-tricks.com/css-basics-using-fallback-colors/
header {
background-color: black;
background-image: url(plants.jpg);
color: white;
}
Basically you first create your fallback background-color, then overwrite it with your background-image. If the background-image doesn't load, the background-color will stay.
For your second question about the text with the .aboutus-card-title class, you have your CSS selectors messed up. This is a good source for learning about selectors: https://css-tricks.com/how-css-selectors-work/. If you want to select that class within main your selector should look like this:
main .aboutus-card-title{
font-size: 30px;
}
In this case, you can probably leave off main and just have this:
.aboutus-card-title{
font-size: 30px;
}
The only reason you would want to use the main selector here is if you wanted to style the .aboutus-card-title class differently if it's within main compared to somewhere else.
These are two questions. I'd split them into two separate posts, makes it a bit easier to search.
For changing the background you can use:
background-color: #82b5cf;
or
background: #82b5cf;
For the centering of text on an image, you could use a combination of position, top, left and transform:
.centered-text {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}

Removing the rectangle from top of web page

This one is taking a lot of time as I can not understand the problem associated with.I am still a newcomer to CSS and don't understand the problem completely .
This is the piece of code from CSS which controls the background of the web page
#intro1 {
height:1000px;
background: #000 url('../innerimages/slide4.jpg');
background-position:center 0px;
background-repeat:no-repeat;
background-size:cover;
}
at this point the web page looks something like this
now if i change the color to fff.i.e
#intro1 {
height:1000px;
background: #fff url('../innerimages/slide4.jpg');
background-position:center 0px;
background-repeat:no-repeat;
background-size:cover;
}
the page looks like this
and this is the html part
<div id="verticalScrollArea" style="display: block; top: -65.27584886649873px;">
<section id="intro1" data-navigation-tag="About SVP 69" style="display: block; background-position: 100% 44.8228px;">
<div id="intro1content" class="content" style="display: block; margin-top: 61.86937866666666px;">
<div class="contentData"> <div class="background">SOME TEXT <br>
<img src="./69 SVP_files/know-more.png">
</div> </div>
<div class="scrollDown"> <span>SOME TEXT</span> <img src="./69 SVP_files/scroll-down.png"></div>
</div>
</section>
What I want is the image to be in full screen .I can not figure it out where am I going wrong in removing the back/white strip ?
How it can be removed
You have to remove margin-top from your #intro1's inline CSS, you can use padding-top instead of margin
The problem is being caused by this line of code:
<div id="intro1content" class="content" style="display: block; margin-top: 61.86937866666666px;">
Specifically, the margin-top that you are applying inline is causing this colored strip to show. Just remove this inline css for margin-top.
There in this ID:
remove the margin-top: 61.86937866666666px;
I don't find any problem with the header section. Only one glitch I saw that a white strange line was appearing. for better explanation check the screenshot.
let me know this is what you want?
okay do you want like this? check the update screenshot?

How do you change background colors of different containers and columns?

Ok, so I'm brand new here (and to programming) and I'm not even sure If the questions I'm going to ask is worded correctly or makes sense, but here it goes.
I am working on a bootstrap theme for a client, I am trying to change the background colors. I do not want the page to be all the same background color. I would like certain rows to have a different background color from the rest of the page. How can I accomplish this? I've tried adding unique tags to the containers I'm working on with the background color I want, but no matter what I do NOTHING is changing. I know this is something simple and I just need a simple explanation as to how to make this work! HELP!
You have some options to do that.
For the background in the divs:
You can do:
<head>
<style>
body{
background-color: red;
}
.backg1{
background-color: blue;
width: 100%;
padding: 10px;}
.content{
background-color: white;
margin: 10px;
width: 80%;
height: 100px;}
</style>
</head>
<body>
<div class="backg1">
<div class="content">
</div>
</div>
</body>
Is only work with the css properties. You need paste the code to try help you.
Add class="bgColor"
Like:
<div class="bgColor">
....
</div>
Your css:
.bgColor{
background: #dadada;
}
Give all your styles in custom_style.css, in which you can add CSS properties for elements. Inside your custom_style.css you give background color you want.That's it, Its just the work of CSS. No other process or procedure to .
consider #Page 1
/* Include Bootstrap.css and custom_style.css etc */
<body>
<div class="container">
<div id="Web_page_home">
.............
</div>
</div>
/* include JQuery.js and Bootstrap.js */
Consider #page 2
/* Include Bootstrap.css and custom_style.css etc */
<body>
<div class="container">
<div id="Web_page_about">
.............
</div>
</div>
/* include JQuery.js and Bootstrap.js */
Here goes the working of CSS "Custom_style.css" has
#Web_page_home { background-color:red; }
#Web_page_about{ background-color:green; }
The output will b the Page 1 backgorund will b in red and another page 2 will be in green.
if you didn't understand still i will attach fiddle.

Bootstrap - Set the Background of a Container

So for example the picture below I'm having typing giving each class="container" it's separate background colour/picture.
<div id="p" class="container">
</div>
style sheet
p.container {
background-image: url(img/this_is_top.png) repeat;
}
CHANGING QUESTION for some reason I have having trouble in setting a background Image* for it.
Regarding your background image problem you currently have
background-image: url(img/this_is_top.png) repeat;
This is wrong. But you are thinking of the background shorthand CSS property which follows this syntax:
#p.container {background:#ffffff url('img/this_is_top.png') no-repeat center center;}
And if you are styling in your stylesheet and your folder hierarchy is the usual (/~/>/img etc) then it should be:
#p.container {
background-image: #ffffff url('../img/this_is_top.png') repeat center center;
}
Notice the double dots before the url to tell CSS to look up a level for the img folder
For starters, having multiple id's with the same name on the same page is not such a great idea. http://css-tricks.com/the-difference-between-id-and-class/

How to achieve following graphics via css

I've set my self a challenge to develop a website without using a single image. I'll mainly use icon fonts, but for this particle graphic, I thought I can use a div or other element and than style it via css e.g. give borders or something... but I discovered that it wasn't as easy as I thought and I can't achieve it.
Here is what I need to get as a final result:
I'm interested in diagonal lines, ignore the background. Is there a way to replicate such lines with help of html or css?
You can do what you ask using css background-image: repeating-linear-gradient()
Lea Verou has a great gallery: http://lea.verou.me/css3patterns/
You can modify diagonial-stripes pattern and get what you want.
Hope this helps you get started..!! Fiddle Demo here..
HTML
<body>
<div class="myDiv"></div>
<div class="myDiv"></div>
<div class="myDiv"></div>
<div class="myDiv"></div>
<div class="myDiv"></div>
<div class="myDiv"></div>
<div class="myDiv"></div>
<div class="myDiv"></div>
</body>​
CSS
.myDiv {
background-color: none;
border: solid 2px #AAA;
margin: 30px;
height: 5px;
-webkit-transform: rotateZ(115deg); // Chrome
-moz-transform: rotateZ(115deg) // Mozilla Firefox
}
Try this,
http://www.patternify.com/
U can make patterns just like that here, and convert it to CSS to use for your background.