I need to nullify (not to counter) effect of parent CSS file - html

First of all, I am working on "rtl" directional web pages.
And, I am using bootstrap component called "breadcrumbs", in my shop.html template. Therefore, I want my breadcrumbs in right to left direction.
<div class="breadcrumb">
<div class="container" align="right">
<a class="breadcrumb-item" href="{% url 'bookrepo:home' %}">صفحہ اول</a>
<span class="breadcrumb-item active"> خریداری </span>
</div>
</div>
I have made my own shop.css file for cutomized styling. Now, issue is that though I have done align:"right" in my template.
But parent file of bootstrap overriding its placement to left. By (https://maxcdn.bootstrapcdn.com/bootstrap/scss/_breadcrumb.scss):
.breadcrumb-item {
float: left;
}
So, it is like that now:
Where I want it to float:right. So what I did in my shop.css is that:
.breadcrumb-item {
float: right;
}
But it didn't go according to plan. It is ruining orientation of breadcrumb. Have a look at it:
So, it means I don't want it to float in neither direction. When I un-apply both it works fine.
Have a look at it:
Obviously, I can erase float:right from my shop.css. So, now guide me to the way to nullify bootstrap's css effect which is float:left.

you need to clear the float
.breadcrumb-item {
clear:both;
float: right;
}

Related

How to align an img and a carousel next to each other, with max-width of 1000px?

I am a beginner and I've ran into an obstacle while trying to align the img (#logo) and the carousel (#my-slider) - both located in #img-header.
Under them there is a navigation bar and under that some text. The site is supposed to hava a max-width of 1000px (the width of the img is 350px and the width of carousel is 630px, so supposably they're both under 1000px), however when trying to align them, carousel jumps under the logo. If I try to align just the carousel with the navbar and text, float:left works (if I change the max-width to 1060) however, float:right does not work at all - it moves to the right, no matter how i change the max-width. All 3, navbar, text and img-header are supposed to be equally wide. The img and carousel "agree" to be in the same line only if I set the max-width to 1880, which also makes the stick to the left and not being centered. I also tried setting the max-width to 1000 and float the logo to left and carousel to right but it also doesn't work - neither does it work if I float both to the same side (for example, both float:left;.
This is how the website is supposed to look like- with this in the center.
Demo of the website
HTML:
<div id="img-header">
<img id="logo" src="logo/logo3.png" style="width:350px;height:240px">
<div class="container">
<div class"row">
<div class="col-sm-12">
<div id="my-slider" class="carousel slide" data-ride="carousel" style="width:630px;height:240px">
<!-- indicators, small dots -->
<ol class="carousel-indicators">
<li data-target="#my-slider" data-slide-to="0" class="active"></li>
<li data-target="#my-slider" data-slide-to="1"></li>
<li data-target="#my-slider" data-slide-to="2"></li>
</ol>
<!-- wrapper for slides -->
<div class="carousel-inner" role="listenbox">
<div class="item active">
<img src="food/food1.jpg" alt="food 1">
</div>
<div class="item">
<img src="food/food2.jpg" alt="food 2">
</div>
<div class="item">
<img src="food/food3.jpg" alt="food 3">
</div>
</div>
<!--navigations/ next and prev buttons -->
<a class="left carousel-control" href="#my-slider" role="button" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
<!--<span class="sr-only">Previous</span>-->
</a>
<a class="right carousel-control" href="#my-slider" role="button" data-slide="next">
<span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
<!--<span class="sr-only">Previous</span>-->
</a>
</div>
</div>
</div>
</div>
</div>
CSS:
#img-header {
max-width: 1060px ;
margin-left: auto ;
margin-right: auto ;
}
#logo {
float: left;
}
#my-slider {
float: left;
}
#navbar {
max-width: 1000px ;
margin-left: auto ;
margin-right: auto ;
}
ul {
list-style-type: none;
overflow: hidden;
background-color: #125ea3;
}
li {
float: right ;
}
li:last-child {
border-right: none;
}
li a {
display: block;
color: white;
text-align: center;
padding: 14px 16px;
text-decoration: none;
}
li a:hover:not(.active) {
background-color: #3594ff;
}
.active {
background-color: #3594ff;
}
.text {
max-width: 1000px ;
margin-left: auto ;
margin-right: auto ;
}
h1 {
text-align="center"
}
p {
text-align="center"
}
I know I am just a begginer so I have probably made quite a few mistakes, please forgive me in advance.
Thanks for all the help and advice in advance!
You've got Probs:
I think I've uncovered some of your main issues. First off, you had a typo (missing = 'equals sign') for your div.row's class declaration.
The biggest issue for this is your structure. I suggest you do some further reading on bootstrap and how it works with the below links.
Also, I've had trouble identifying what your main goal was regarding responsivity, so you have 3 versions that all do different things. Let me know if I made a typo or forgot about something.
Here's what I did:
I went ahead and rebuilt your HTML structure using a generator (linked below). I figured this would be okay since you probably should re-build (yes, again, and on your own using the documentation if you want to learn how things work) the layout a 2nd time anyways.
Demos:
http://codepen.io/anon/pen/VjdRJK (Version 1)
http://codepen.io/anon/pen/QExPmP (Version 2)
http://codepen.io/anon/pen/PzaLwk (Version 3)
Further Reading:
http://www.layoutit.com/build (used generator system)
http://getbootstrap.com/css/#grid (read this please)
http://getbootstrap.com/customize/ (customize Bootstrap here)
Quick breakdown of Bootstrap (below)
Quick Breakdown of Bootstrap:
Bootstrap is a really nifty system, but I often see it get overcomplicated and used incorrectly thereafter. I think it'd be helpful if we simplified things regarding what Bootstrap actually is in order to bring some clarity to the issue. I'll write more if requested.
First off:
Bootstrap is a framework:
This means that Bootstrap is simply just a pre-made foundational structure that your code is built off of.
This also means that Bootstrap is intended to be customized. This link will show you that: http://getbootstrap.com/customize/ (also placed in the list for convenience)
Go ahead and click on that link and note how the 'customizer' actually works. It's essentially a really big form that you fill out which sets variables to appropriately change the downloadable package's contents. You'll see that one of the very first sections is a variety of checkboxes that allows you to not only change their settings/formats/etc., but also remove specific components entirely, like jQuery plugins or Javascript Components.
Bootstrap covers HTML, CSS, and Javascript
Consider this Analogy: it's best to use a concrete foundation to construct a building upon - although it's certainly possible to build a house without a rock-solid, ground-embedded concrete base of a foundation, it certainly won't adapt to & survive the future storms of obsoletion and changes to the land.
The meaning behind it: Not that it's impossible to create a great front-end presentation without them, but frameworks like Bootstrap totally rock. They address a multitude of potential issues and problems related to possibly unexpected results, they take care of a lot of the repeated, preamblic code, and they're incredibly flexible: able to be customized, reduced, enhanced, etc.
Often Overlooked: One hidden gem/benefit is that Bootstrap (much like every other widely-used framework/system, like Drupal, Magento, or Wordpress) inherently creates a reliably (usually) consistent set of standards that aren't only easy for (almost) everyone to adhere to (most without even knowing it) but are also easy for (almost) everyone to understand (like when debugging for others on StackOverflow).
Here's the key:
Bootstrap simply has a bunch of extra stuff: they don't know exactly what you'll need for whatever you're doing, but they've made a pretty good assumption that it'll undoubtedly include usage of the grid system, images, and a few components like jumbotrons or callouts. The option is left up to you what you do (and) don't include in your Customized Bootstrap download.
And that's it. Those are the basics. Nothing crazy to it except some fantastic innovative insight, courtesy of its creator(s). Though it handles a LOT more than your trusty ol'e CSS Reset and CSS Normalize, it's quite a bit less intimidating if you treat it like a CSS Reset on super code steroids.
That's all!
Documentation of bootstrap has everything. You just need to look for it.
http://getbootstrap.com/css"
And I think your problem can be solved by
<div class="row">
<div class="col-md-4">
<!--Logo Comes here-->
</div>
<div class="col-md-8">
<!--Carousal Comes here-->
</div>
</div>

Using CSS to Highlight Current Page

I want to highlight current page by using CSS, but somehow it doesn't work. Please take a look at my code below.
HTML
<body id="home">
<div id="mainNav">
<a href="/Dashboard/Index" id="navIndex">
<div class="circle text-uppercase">
<div class="icon23X27"><img src="~/Content/icons/dashBoard.png" width="23px" height="27px" align="middle" /></div><span class="textStyle">Dashboard</span>
</div>
</a>
<a href="/samples/register/" id="navRegister">
<div class="circle text-uppercase">
<div class="icon23X27"><img src="~/Content/icons/samples.png" width="23px" height="27px" align="middle" /></div><span class="textStyle">Sample Registration</span>
</div> </a>
<a href="/samples/search/">
.........
</div>
CSS
body#/samples/register a#navRegister .textStyle {
background-color:red !important
}
The syntax is wrong. Use this way:
body a#navRegister[href="/samples/register"] .textStyle {
background-color:red !important
}
Yours is a worst example of having div inside <a>, which is similar to having a bottle inside some water, not water inside bottle, which is right one.
Take your body ID, in this case #home and combine it with the id on the home nave element, in this case #navIndex:
#home #navIndex .textStyle {
background-color: red;
}
Then you can add a selector for each of your pages to catch the current page in the nav with css alone:
#home #navIndex .textStyle,
#register #navRegister .textStyle {
background-color: red;
}
Drop the !important it's only necessary in a couple of edge cases in css and should be avoided (I appreciate one of those edge cases is just trying to definitely make a selector show some visible effect, which may well be what you're doing with the posted css).
You'd also benefit from using classes instead of ids as css selectors.
Caveat:
It's probably better to render this in the html server side as the server can use the request URL to decide which nav item is current. That way you can just add a selected-nav-text class to your current nav span and your css becomes:
.selected-nav-text {
background-color: red;
}
This is simpler, you can write logic once server side to calculate the current nav and css once to highlight it, then when you change your nav the functionality will come instantly.

CSS - Images side by side in Wordpress

I have tried using the code provided at http://jsfiddle.net/heera/X3b5g/1/, and when I input my own variable names/images in the fiddle it works fine.
But I then put the CSS code into my child theme style.css and the HTML in my page and the images show one on top of the other, not side by side as I need. I'm not using variables that could be clashing and I'm driving myself insane with this - it is something in Wordpress that stops this from working.
.my-side-by-side {
display: inline-block;
margin-left: auto;
margin-right: auto;
height: 50px;
}
#my-button-centred {
text-align:center;
}
HTML:
<div id="my-button-centred">
<a href=""https://itunes.apple.com/us/app/belize-travel-guide-paid/id792977226?mt=8">
<img class="my-side-by-side" border="0" alt="" src="http://hotguidebelize.com/wp-content/uploads/apple-store.png" alt="" /></a>
<a href="https://play.google.com/store/apps/details?id=com.app_belizeguide.layout">
<img class="my-side-by-side" border="0" alt="" src="http://hotguidebelize.com/wp-content/uploads/google-store.png"/></a>
</div>
If I take out the div id and just use the div class, I do get the buttons side by side, but then they are not centred. What am I doing wrong?
Your code is working perfectly in fiddle: right here
Can you check the source code while testing it, and make sure no other styles overwriting it?,
if so try adding !important in the end of overwrited styles
Whenever you use a child theme you have to be mindful of any CSS from the parent theme. You may have to override some things from the parent theme.
some examples might be
margins
padding
position
display
You will have to inspect the element to see every CSS value that is being set that is not in your child theme and find which one(s) are causing it to display improperly.

Remove styling on a center tag

I am working with a system that outputs the following syntax (which I can't change)
<body>
<div class="page">
<center>
[The page contents]
</center>
</div>
</body>
I would like to nullify the formatting on the <center> element as it is messing with my responsive layout. Any ideas how to nullify the style on this element?
What about using jQuery to rewrite the content of the after-the-fact? Something like:
$(".page").replaceWith($(".page center").contents());
See it in action: http://jsfiddle.net/5fuBm/1/
It depends on exactly what you need to do, but you can use css on the center element like so:
center {
text-align: left;
}
or maybe:
center {
float: left;
}
Try out some different things and see what works best.

Align social buttons correctly

I am trying to put social buttons facebook and tweetmeme in our site. I liked the way it's done in yahoo sites. Please look
Yahoo Link
I looked at yahoo code, but the implementation style is very difficult to understand. It would be great if someone can help me in html/css coding.
Thanks.
Update
This is the code I have so far.. The issues I am having is Yahoo customized the css by changing the facebook and tweetmeme css behavior. Please check the attached image and compare with it. The code I am using is
<a name="fb_share" type="button_count" share_url="http://www.yahoo.com" href="http://www.facebook.com/sharer.php">Share</a><script
src="http://static.ak.fbcdn.net/connect.php/js/FB.Share" type="text/javascript"></script>
<script type="text/javascript">
tweetmeme_url = 'http://www.yahoo.com';
tweetmeme_style = 'compact';
</script>
<script type="text/javascript" src="http://tweetmeme.com/i/scripts/button.js"></script>
Please let me know, can we have exactly they have. I liked the look and feel of that. :)
Thank You.
I solved this for http://www.easynda.com using tips from http://neilgoodman.net/2012/01/14/making-social-buttons-line-up-in-a-row-in-css/ and some refinements.
I started by trying to use margins or padding in CSS to adjust the position of the social buttons, but that didn't work. Each button has slightly different margins and padding, which meant my adjustments never worked right and didn't look the same across browsers.
What's needed is to be able to accommodate the variation between buttons and to get them to stay where I put them in my HTML. The solution to is using floats. Max Design has a nice tutorial on floats with examples here: //css.maxdesign.com.au/floatutorial/introduction.htm.
Following the tips from Neil's site got me to here - but with clear problems.
(I'd post an image, but don't have enough reputation points yet).
The LinkedIn button sits at the top of its DIV while the FB buttons sits in the middle of it's DIV as seen in the first image. There are a couple of issues to note:
a: the FB share button width is minimum 90px per //developers.facebook.co.... All well and good, however, the width is dynamic based on the number of shares one has.
b: there is no margin between the FB share and LI share button -
c: the LI share button needs more width, and dynamic width as it will get it's own count as time goes on.
c: 20 px height is not enough for FB - even thought the FB button is only 20px, the JS adds pixels above the visible button. Also note that the bottom of the count bubble is cut off
d: and most obvious of all, the vertical positioning with LI riding high.
I solved the problem by floating a container holding the buttons with a line-height if 1 and using some CSS to float the buttons displayed inline with a min width, min height, and left padding.
The results are what was live as of the date of this posting (again, need reputation points to post images and more than two links)
Here is my HTML and CSS:
<div class="social-button-container" style="position: relative; z-index: 999;">
<!-- Facebook -->
<div class="social-button fb-like" data-href="http://easynda.com" data-layout="button_count" data-action="like" data-show-faces="false" data-share="true"></div>
<!-- LinkedIn -->
<div class="social-button">
<script type="IN/Share" data-url="http://www.easynda.com" data-counter="right"></script></div>
<!-- Twitter -->
<div class="social-button">
</div>
<div style="clear: both;"></div>
</div>
.social-button-container {
/*background-color: red;*/
/**
* This is a nice CSS trick that allows you to clear an element
* without having to add extra elements to your HTML. This helps
* separate content from design, which should always be an architectural
* goal.
*/
float: left;
line-height: 1;
}
.social-button {
float: left;
min-width: 100px;
display: inline;
min-height: 22px;
padding-right: 5px;
}
They are using an unordered list at the elements to show the buttons.
A UL is mostly used to show a list of items vertically but you can use CSS to make the items appear next to each other instead.
<ul>
<li style="display:inline">One</li>
<li style="display:inline">One</li>
</ul>
I think the above would work ok.
All you need to do then is right align it.
<div style="width:400px">
<ul style="float:right">
<li style="display:inline">One</li>
<li style="display:inline">One</li>
</ul>
</div>
Don't forget to use classes instead of inline styles like I have here.
Well, you basically just have to deal with the fact that one is an inline (a) element, the other a block (iframe) element, after that it becomes quite easy, just test that:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style type="text/css">
#fb_share, iframe {
display: block;
float: left;
line-height: 2em;
margin: 0 1em 0 0;
}
</style>
</head>
<body>
<a id="fb_share" name="fb_share" type="button_count" share_url="http://www.yahoo.com" href="http://www.facebook.com/sharer.php">Share</a>
<script src="http://static.ak.fbcdn.net/connect.php/js/FB.Share"></script>
<script>
tweetmeme_url = 'http://www.yahoo.com';
tweetmeme_style = 'compact';
</script>
<script src="http://tweetmeme.com/i/scripts/button.js"></script>
</body>
</html>
Put your social media buttons into parent divs and give those divs an id each.
Target the inner iframe elements, e.g:
#fblikeblock iframe, #gplusblock iframe {
vertical-align: top !important;
}
where fblikeblock and gplusblock are the parent divs.
and use this on your parent divs:
#fblikeblock, #gplusblock {
display: inline !important;
position: relative;
zoom: 1;
}