The display of my code change when I add bootstrap link? - css

So I plan to make my login page responsive using bootstrap. But when I add bootstrap link in my code, the display of my HTML is affected for some reason. I wanna know why is that, and can you give me a tip how can I make my login page responsive?
Here is the image if there is bootstrap link added:
Here is the image if there is no bootstrap link:
My code:
body {
width: auto;
margin:0;
padding:0;
}
#font-face {
font-family: "Gidole";
src: url(CODE Light.otf);
}
h2 {
text-align: center;
}
.container {
width: 960px;
height: 500px;
margin-left: auto;
margin-right: auto;
position: relative;
}
.row {
width: 320px;
position: absolute;
top: 60%;
left: 50%;
transform: translate(-50%, -50%);
color: #191919;
background-color: green;
box-shadow: 0 1px 1px #ABBEB5;
font-family: "Gidole", sans-serif;
padding: 10px 55px 40px;
border: 1px solid black;
}
input[type=text],[type=password] {
width: 97%;
height: 22px;
padding-left: 5px;
margin-bottom: 20px;
margin-top: 8px;
color: #191919;
font-family: "Gidole", sans-serif;
margin-top:5px;
}
#login {
width: 100%;
margin-top: 5px;
padding: 10px;
font-weight: bold;
cursor: pointer;
/* display: block; use for centering */
display: block;
color: #000000;
}
#signup {
color: #191919;
margin-top: 5px;
cursor: pointer;
font-size: 12px;
text-align: center;
display: block
}
#forgotpass {
color: #191919;
cursor: pointer;
font-size: 12px;
text-align: center;
display: block
}
<link rel="stylesheet" href="bootstrap/bootstrap-3.3.7-dist/css/bootstrap.min.css" />
<div class="container">
<div class="row">
<h2> User Login </h1>
<div class="myForm1">
<form action="p1.php" method="POST">
<input type="text" name="username" placeholder="Username" /> <br/>
<input type="password" name="password" placeholder="Password" /> <br/>
<input type="submit" name="submit" id="login"/>
</form>
<form action="register.php" method="POST">
<p> Sign up </p>
<p> Forgot password? </p>
</form>
</div>
</div>
</div>

Twitter Bootstrap is a collection of css and js components ready to be used in your project.
You used some class names used by Bootstrap in your project. Without loading Bootstrap, the rules defined in the library for those classes do not apply, because you're not loading the library. When you load it, they apply.
Some of the classes used by you and which Bootstrap styles up are: container and row. You should take some time and look through their examples and also inspect the applied CSS rules to better understand what each does.
Also, when you decide to use Bootstrap, best practice (by far) is to start from their provided examples and try to keep modifications to a minimum, especially regarding layout.
Please note Bootstrap provides fixes and solutions for most common layout problems such as
browser rendering differences
responsiveness
But, again. Bootstrap is not a robot which analyzes and fixes your page. It's just a collection of CSS rules, #media queries (and sometimes small js snippets). If you plan on using it, you need to learn what each of those components does.
Pretending it works out of the box is like pretending a plane to fly itself. Some do, but it's still best you know how to steer, land and take-off, just in case the automatic systems fail.

To further elaborate what #Andrei Gheorghiu answered, Kindly open
up your console on your Google Chrome browser (right click then 'Inspect Element' or press Ctrl + Shift + I or F12)
You can see in the image that your class {container} from your [style.css]
{width} property was override by Twitter Bootstrap [bootstrap.min.css] class {container} property (check your console).
CSS properties will change depending on the importing order of your css files. In this case, I import the css files in this order:
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"/>
<link rel="stylesheet" href="style.css" />
This means that the css properties will start off by [bootstrap.min.css] follow by [style.css]
So if we reverse the order like this:
<link rel="stylesheet" href="style.css" />
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"/>
This will happen:
And this one....
Now the Twitter Bootstrap [bootstrap.min.css] class {container} property overrides your [style.css] class {container} property.
You can also see that there's a prefix here '#media'. You can learn more about using #media queries
to make your login page responsive here: https://css-tricks.com/snippets/css/media-queries-for-standard-devices/
But like #Andrei mention, you can start of your login page layout from Bootstrap's provided example and keep your styles to a minimum if possible. Hope this helps for you.

Related

There's a new Telegram "button" for websites - need help to use it on blogspot

I'm trying to implement this button for my blog (on Blogger) but I can't really understand how it works, take a look at this post (you will see the Telegram Button with the type "Forward" at the end of the post): https://telegram.org/blog/supergroups
I found the HTML, this is the markup:
<i class="tl_telegram_share_icon"></i><span class="tl_telegram_share_label" target="_blank">Forward</span>
and this is the CSS:
.tl_telegram_share_btn {
display: inline-block;
border-radius: 15px;
background-color: #54a9eb;
cursor: pointer;
line-height: 22px;
margin-right: 15px;
padding: 5px 12px 5px 5px;
color: #FFF;
font-weight: bold;
}
i.tl_telegram_share_icon {
display: inline-block;
width: 22px;
height: 22px;
background: url(/img/share_logo.png) 0 0 no-repeat;
background-size: 22px 22px;
margin-right: 7px;
vertical-align: top;
}
.tl_telegram_share_label {
line-height: 21px;
vertical-align: top;
display: inline-block;
/* margin-top: 1px; */
}
Despite the CSS, seems that the tricky part resides on the HTML markup, I understand that under blogspot there are some html tags and parameters to use, as:
data:post.canonicalUrl
data:post.title
I was trying to do it, using data:post.canonicalUrl in "data-url", and inside the href value, but nothing works.
For Blogspot use this code:
<a expr:href='"https://telegram.me/share/url?url=" + data:post.url + "&text=" + data:post.title'>Share on Telegram</a>
It's a Telegram function, where you call the url, it returns a deep-linked URI for apps to open certain action. For this case, you're sharing the link, so it's "/share/url?url=...".
To use the button, you can either put CSS to your blog(if blogspot/Blogger allows), then add CSS class to the "Forward" button:
<a href="//telegram.me/share/url?url=myURL&text=myTEXT" class="tl_telegram_share_btn">
<i class="tl_telegram_share_icon"></i>
<span class="tl_telegram_share_label">Forward</span>
</a>
Or, you can place a picture for the link itself:
<a href="//telegram.me/share/url?url=myURL&text=myTEXT" class="tl_telegram_share_btn">
<img src="/path/to/mybtn.png" class="tl_telegram_share_img" />
</a>
Simply Insert this code and add some CSS according to your Other share icons
<a class='telegram' expr:href='"https://telegram.me/share/url?url=" + data:post.title + "%20%2D%20" + data:post.url' rel='nofollow' target='_blank'/>
Example CSS using font awesome icons
.telegram{background:#2DA5D9}.telegram:before{font-family:FontAwesome;content:"\f2c6&quot}
Here are your URL options for telegram.me.
https://t.me/share/url?url={url}&text={text}
https://telegram.me/share/url?url={url}&text={text}
tg://msg_url?url={url}&text={text}
The official API documentation source: Core.Telegram.org: Widgets -> Sharing Button
They suggest the t.me format, not telegram.me. You may share:
url : The URL you want to share.
text : Text to accompany the URL you want to share.
If you are interested in watching a project that keeps track of these URLs, then check us out!: https://github.com/bradvin/social-share-urls#telegramme

Internal CSS not overriding external CSS for class

I need my "column" class in the internal CSS to float center while the external CSS has it set to left.
Here is my CSS file:
body { text-align: center; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; }
#report { width: 1269px; margin: auto; float: left;
}
div.column{ margin-top: 10px; padding: 0px 0px; float: left; }
div.first{ padding-right: 8px; border-right: 1px grey solid; }
div.second{ margin-left: 8px;
}
...
Here is my HTML with internal CSS:
<!DOCTYPE html>
<html>
<head>
<title>Dual Server Report</title>
<link rel="stylesheet" type="text/css" href="ServerReport.css">
<style type="text/css">
div.column{ float: center; }
</style>
</head>
<body>
<div id="report">
<h1>Automated PowerShell Install Report</h1>
<h2>This report was ran: 07/07/2015 09:03:21</h2>
<div class="column">
...
I checked out these three similar questions but nothing I tried worked.
Internal Stylesheet NOT overriding External stylesheet?
“Inner” CSS Not Overriding “Outer” CSS
Overriding External CSS
Edit:
I remembered looking up the "float" property yesterday but I did not remember what I found; I feel pretty silly for posting this before going to double check. It makes sense that float would not have a center property.
I'll leave this up in case anyone in the future makes a similar mistake. Thanks to everyone who answered for being so respectful in pointing out this error I should have found on my own.
The property value of float: center does not exist.
The float property has four values: left, right, none, and inherit.
The only valid values for float are: left, right, none, inherit.
So this code will be skipped and not override the css file.
Please look here for more information on the float property.
There is nothing like float: center in CSS
Another way to do it
Change your CSS under the html page
div.column
{
float: none;
margin: auto;
width: 200px; /* set the width (Except 'auto') */
}

What is the HTML entity for a search icon? [duplicate]

This question already has answers here:
Is there Unicode glyph Symbol to represent "Search" [closed]
(5 answers)
Closed 5 years ago.
I'm trying to put a search icon in the navigation bar of my webpage but I'm not willing to use image for the purpose. Is there a HTML entity for a search icon used in search engines or search bars in different websites. I know most of them use images but is there any HTML entity for it?
Thanks in advance.
EDIT: I am providing the code
<li> **SearchIconEntityToPutHere**
<ul>
<li><form id="searchbar">
<input type="text">
</form></li>
</ul>
</li>
HTML
Use 🔍 for 🔍 and 🔎 for 🔎
CSS (content string)
Use '\1F50D' for 🔍 and '\1F50E' for 🔎
As noted in comments, this depends on font and unicode support.
I suggest you stick with using an image or sprite sheet for this purpose to ensure that it's supported.
Update: Fonts
A new method for this is through the use of special font frameworks, which use a combination of web fonts and CSS helper classes. One example is Font Awesome (the example below uses the search icon):
<i class="fas fa-search" aria-hidden="true"></i>
Using this method has the benefit of having something that can be resized without a change in quality, as well as being subject to CSS rules like any other text, so rules like color and text-shadow can affect it.
How about using css and html only? This is what I did (can be improved):
<!DOCTYPE html>
<html>
<head>
<meta charset= "UTF-8">
<title> A css trick </title>
<style type="text/css">
body{
background-size: 100%;
background-color: #000;
color: orange;
font-size: 18px;
margin: 0 auto;
text-align: center;
}
#search_box{width: 60px; position: relative; margin: 0 auto; transform: rotate(26deg)}
#search{width:10px; height: 10px; border: 3px solid #f5f5f5; border-radius: 10px; float: left;}
#cabe{width: 8px;display: block; border: 2px solid #fff;color: #f6f6f6; font-weight: bold; text-shadow: 2px 0px #fff; position: absolute; top: 6px; left: 13px; font-size: 16px; border-radius: 10px;}
</style>
</head>
<body>
<h1>CSS TRICK</h1>
<div id="search_box"><div id="search"></div><span id="cabe"></span></div>
</body>
</html>
There is no HTML entity that could be reasonably regarded as denoting a “search icon”.
Depending on what you mean by “search icon”, there may or may not be a Unicode character that represents it. See Is there Unicode glyph Symbol to represent "Search". If there is, then it can be written as a character reference in HTML, though this is rather immaterial; the important thing is that most fonts would not contain it.

CSS doesn't work on single div, others get changed

I'm currently working on a website design and need to make some changes to an advertisement. The CSS I apply to the main div (.ad_728x90_home) I'm targeting doesn't work. I have applied a margin-top to the div but that doesn't work, tried other CSS but it's not getting picked up.
Any help would be greatly appreciated! The advert is located below the second post.
.ad_728x90_home {
height: 130px;
}
.ad_728x90_home_text {
margin-top: 40px;
}
span.ad_728x90_home_h3text {
color: #FFFFFF;
float: left;
font-family: LeagueGothicRegular;
font-size: 23px;
line-height: 34px;
margin: 13px 0 22px 10px;
text-transform: uppercase;
width: 185px;
}
.ad_728x90_image {
float: right;
margin-right: 10px;
}
<div class="ad_728x90_home">
<div class="ad_728x90_home_text">
<span class="ad_728x90_home_h3text">Need more quality fonts? Head over to myfonts.com</span>
</div>
<div class="ad_728x90_image">
<img class="scale-with-grid" src="images/ad_728x90.jpg" alt="Blog Post" />
</div>
</div>
Be sure you have the right class names between .ad_728x90_home and .ad_728x90_home_text and double check your HTML nesting.
I checked your items with Chrome's inspect element and the <div class="ad_728x90_home_text"> seems to start above your ad, at the top of the page.
Try going to make it a position:relative as it seems like a main div element
.ad_728x90_home {
Postion:relative;
top:10px;}
I cannot say the exact pixel amount of it as the margin-top doesnt work try using it as relative.

Best Image Replacement Technique

What is the best (as in cross-browser) technique to do image replacement in CSS? I am using sprites to do my navigation, but I want the markup to remain SEO friendly. Given the following HTML structure...
<div id="menu">
<ul>
<li>Test</li>
<li>Tester</li>
<li>Testing Testing</li>
</ul>
</div>
What is the best way to replace the text with a background image using CSS only?
I am currently using this...
text-indent: -9999px;
But, it fails with CSS on, and images off.
If this is the html:
<div id="menu">
<ul>
<li>Home</li>
<li>About</li>
<li>Contact</li>
</ul>
</div>
And this is the css:
#menu ul li a{
display: block;
overflow: hidden;
text-indent: -9999px;
background: transparent url(yourpicture.png) no-repeat 0 0;
width: 100px;
}
#home{
background-position: 0px 0px
}
#about{
background-position: -100px 0px
}
#contact{
background-position: -200px 0px
}
The image would then be 300px wide, and each tab would be 100px wide.
In 2008, Google's presentation at An Event Apart made it clear that valid image replacement will not be penalized by Google. See Mezzoblue's post about it
Basically, as long as the image you replace the text with has the same text in it, it will be considered valid and not trying to cheat search engines. How do they determine whether the image is valid or not? I have no idea... OCR? Manual review?
As far as CSS on/images off, there is no perfect solution, all of them require extra non-semantic markup. See the css-tricks link that beggs posted on the different techniques. I personally do not bother with the very small percentage of users who browse with CSS but no images.
Your choice is simple. Extra markup, or don't care about css on/images off.
The background image is usally applied to the <a> link, giving the entire clickable area an image. To hide the text you can use a very big negative value for text-indent.
I just came up with this, it seems to work in all modern browsers, I just tested it then on (IE8/compatibility, Chrome, Safari, Moz)
HTML
<img id="my_image" alt="my text" src="images/small_transparent.gif" />
CSS
#my_image{
background-image:url('images/my_image.png');
width:100px;
height:100px;}
Pro's:
image alt text is best-practice for accessibility/seo
no extra HTML markup, and the css is pretty minimal too
gets around the css on/images off issue where "text-indent" techniques still hide text for low bandwidth users
The biggest disadvantage that I can think of is the css off/images on situation, because you'll only send a transparent gif.
It might be possible to write a little javascript to help out with this, replacing all the image sources with their background-image css properties. But this would only work if the browsers still attaches css properties to elements and then ignores them. I don't know if this is the case or not, I'll have to test it out. You'd also want to develop a javascript-based test to see if css is being applied to the page (maybe check the position of some test element).
btw, I'd like to know, who uses images without stylesheets? some kind of mobile phone or something?
edit:
Based on comment below... inline styles hrm... maybe I should just make a php helper function like <?php echo css_image('image_id','my text','image_url');?> to generate some code like this:
HTML
<div id="image_id" style="background-image:url('image_url')" class="image">
<img src="image_url" class="alt_text" alt="my text" />
<p>my text</p>
</div><!--/#my_image-->
then just attach some CSS in the stylesheet
#image_id{width:*image width*;height:*image height*}
.alt_text{position:absolute;top:0px;left:0px}
.image{display:block;background-position:left top}
.image p{position:absolute;left:-9999em}
it's an older technique that I'm using, not sure where I found it though. It works with CSS on/images off, CSS off/images on, CSS on/images on.
If a user with CSS off/images off visits, they'll see doubled up text. If a search engine spider visits, they'll see alt text and regular text, an intelligent spider could easily identify this for what it is, an innocent image replacement technique.
So, this technique is worst for screen readers, since alt text is read, but these users should be able to skip to the next paragraph, which is why I stuck <p></p> around "my text".
Everyone else with both CSS and images turned off is some kind of bot, right?
#menu ul li a {
display: block;
background-image: url(images/someimage.png);
text-indent: -9000px;
width: 454px;
height: 64px;
}
The display:block is important or else your width and height may not look right.
This is the code I use for replacing logo text with an image while keeping the text in the code but not shown to the user (this is Google approved). View the completed example here:
http://discretiondesigns.com/overflow/imagereplacement/
Here's the full code (images can be found at the above link - images can be varying sizes - the entire image is clickable and changes upon hover):
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Image Replacement</title>
<style type="text/css">
<!--
#menu li { list-style: none; }
#menu #a { font: .9em Verdana, Arial, Helvetica, sans-serif; color: #E9E7E0; height: 20px; width: 100px; padding-top: 8px; padding-left: 8px; float: left; }
#menu #a a { background: url(http://discretiondesigns.com/overflow/imagereplacement/a_off.gif) no-repeat left top; height: 20px; width: 100px; display: block; }
#menu #a a:hover { background: url(http://discretiondesigns.com/overflow/imagereplacement/a_on.gif); }
#menu #a span { display: none; }
#menu #b { font: .9em Verdana, Arial, Helvetica, sans-serif; color: #E9E7E0; height: 20px; width: 100px; padding-top: 8px; padding-left: 8px; float: left; }
#menu #b a { background: url(http://discretiondesigns.com/overflow/imagereplacement/b_off.gif) no-repeat left top; height: 20px; width: 100px; display: block; }
#menu #b a:hover { background: url(http://discretiondesigns.com/overflow/imagereplacement/b_on.gif); }
#menu #b span { display: none; }
#menu #c { font: .9em Verdana, Arial, Helvetica, sans-serif; color: #E9E7E0; height: 20px; width: 100px; padding-top: 8px; padding-left: 8px; float: left; }
#menu #c a { background: url(http://discretiondesigns.com/overflow/imagereplacement/c_off.gif) no-repeat left top; height: 20px; width: 100px; display: block; }
#menu #c a:hover { background: url(http://discretiondesigns.com/overflow/imagereplacement/c_on.gif); }
#menu #c span { display: none; }
-->
</style>
</head>
<body>
<div id="menu">
<ul>
<li id="a"><span>Nav A</span></li>
<li id="b"><span>Nav B</span></li>
<li id="c"><span>Nav C</span></li>
</ul>
</div>
</body>
</html>
This is touted to work no matter the settings of css/images:
http://www.tjkdesign.com/articles/tip.asp
CSS Tricks has one of the most detailed posts on the subject here
They show various techniques. The one that solves your problem of css on and images off is:
HTML:
CSS Tricks has one of the most detailed pages on the subject here
They show various techniques. The one that solves your problem of css on and images off is the technique #8:
HTML:
<div id="menu">
<ul>
<li><span></span>Test</li>
<li><span></span>Tester</li>
</ul>
</div>
CSS:
#menu a {
width: 350px; height: 75px; /*your values here*/
position: relative;
}
#menu a span {
background: url("images/li.jpg"); /*your image here*/
position: absolute;
width: 100%;
height: 100%;
}
EDIT: Updated the code to the sample provided.
PS: I didn't test the code above.
CSS:
#menu ul li a{
display: block;
background-image: url(http://example.com/sprite.png);
width: 100px;
height: 50px;
}
#a {
background-position: <offset for sprite>;
}
#b {
background-position: <offset for sprite>;
}
#c {
background-position: <offset for sprite>;
}
HTML:
<div id="menu">
<ul>
<li id="a">Test</li>
<li id="b">Tester</li>
<li id="c">Testing Testing</li>
</ul>
</div>
Edit: added the link text back in... 'cause it was missed. :-)

Resources