Aligning div elements side-by-side - alignment

I have a page on a project I'm creating for class where I wanted to align an image in the left side, with the text to the right aligned in the middle of the image. Instead of using html elements, I decided to try an internal CSS div elements within my external CSS. My problem is that I can't get them to align correctly vertically. I have the horizontal alignment, but the text either appears one line above or one line below the image. I tried the techniques included in this posting, but they didn't fix my problem. Align <div> elements side by side
Here is my internal CSS.
<style type="text/css">
/* left div holding the image */
#left {
width:170px;
align:left; }
/* right div to hold the text */
#right {
margin-left: 200px;
text-align:left; }
</style>
Here's the HTML
<div id="content">
<br/>
<br/>
<br/>
<blockquote>
<div id="right">Check back soon. Click here to receive an email when the site becomes available.</div><div id="left"><img src="images/construction-clipart.jpg" border="1" alt="Page under construction" /></div>
</blockquote>
</div>
Can you help me figure out how to make these align? To view how it is rendering, please visit my student project site at http://www.student.nvcc.edu/home/ligomes/TwoWiredChicks/Browse.html.
Thanks!

Finally, I hope this helps now. All you have for the right css is:
#right {
position: absolute;
margin-left: 200px
}

Related

Bootstrap .... Removing margin of div container

<div class="row row-cols-1 row-cols-md-3 g-4">
.I want to remove the left and right margin of this div container using bootstrap.
For removing it I have used the class mx-0.
Like This
<div class="row row-cols-1 row-cols-md-3 g-4 mx-0">
But its Not Working .
How to solve this issue ? . Thanks
There is no margin set for any of those classes. Your margin is coming from parent class ... e.g. <body> sets a margin of 8px.
You need to set the mx-0 in the parent. Or override your div with some custom css, e.g.,
margin-left: -8px;
margin-right: -8px;
(This is not exactly what you need, but I don't have your parent code so showing you an arb. example.)

Jquery Mobile Footer NavBar Horizontal Scroll

I'm using the "navbar" data-role for a div inside JQuery Mobile's footer definition. When I add more than 5 items it divides the menu items into two columns. This is default behaviour according to the JQM documentation. I'd like the icons to be scrollable by swiping left or right inside the footer area.
<div data-role="footer" data-theme="d" data-position="fixed" id="divFooter">
<div data-role="navbar" id="divNavBar">
<ul>
<li>Profile</li>
<li>Status</li>
</ul>
</div>
</div>
For reference, I looked at this potential solution: JQM horizontal scroll navbar. It however turns the menu icons into HTML links and works inside the header data-role.
Any ideas?
What you need is the following on your parent div (on your footer div)
overflow: auto;
white-space: nowrap;
The nowarp makes the div contents not overflow to the next line and the overflow auto makes it scrollable in whichever direction it will not fit which in this case is horizontal since we turned off word wrap
You may achieve this with HTML/CSS only:
HTML
<header>
<nav role='navigation'>
<ul>
<li>Home</li>
<li>About</li>
<li>Clients</li>
<li>Contact</li>
</ul>
</nav>
Menu
</header>
CSS
nav {
overflow-x: scroll; /* 1 */
-webkit-overflow-scrolling: touch; /* 2 */
}
ul {
text-align: justify; /* 3 */
width: 30em; /* 4 */
}
ul:after { /* 5 */
content: '';
display: inline-block;
width: 100%;
}
li {
display: inline-block; /* 6 */
}
Comments:
Setting auto will work on some devices, but set this to scroll just
to be sure.
This the magic property that enables the native feel
scrolling.
Setting this to justify creates equally spaced li's which
takes the headache of working out margins.
You must set the width to
a value larger than the sum of all the li's width.
This is text-align: justify's version of a clearfix.
This must also be set for the equal spacing to work.
Should work on the following devices:
iOS 5+
Android 3.0
Blackberry 6+ (didn't check personally)
Windows Phone (IE10) supports momentum scrolling natively
Taken from here: http://hugogiraudel.com/2013/08/23/scroll-overflow-menu/

Stop heading being shortened for jQuery Mobile collapsible content?

I have the following collapsible content with jQuery Mobile. How can I stop the heading being shortened?
At the moment the text is cut off so it reads something like 'Really long heading...' Do I need to do this manually with css or is there a JQB setting I can change?
<div data-role="collapsible">
<h4>
Really long heading goes here thats wider than the page width
</h4>
<p>
Content Content Content Content Content Content
</p>
</div>
Here is the documentation
http://jquerymobile.com/test/docs/content/content-collapsible.html
It seems this CSS is causing the behavior. I could overwrite this rule if there isnt a standard JQM method for doing this.
.ui-btn-inner {
white-space: nowrap;
}
You need to remove this css:
white-space: nowrap;
from its inner span (span witch wrap's text). Or replace it with:
white-space: normal;
Or change jQM css file (.ui-btn-inner) but this will also effect every other element using this class.
Or use this line:
$('div[data-role="collapsible"] h4 a span span.ui-btn-text').css({'white-space':'normal'});
There's no other way, or at lease not buy changing some jQM UI element attribute.

Twitter Bootstrap & rails - center content and fix min width

In my html the content should be centered on screen and his width should never be greater then 950px.
Since I want this same html to show on mobile and desktop I am using twitter bootstrap to make the layout responsive.
The problem is: I cant seem to make the content div to be centered AND have the max width of 950px.
When I open on a browser the css has this media query:
#media (min-width: 1200px)
that makes my div always fit the entire screen.
How can I fix this?
Basically what I want to do is something like this:
The orange line is the container (or body) and the blues are the rows
Thanks for any help.
EDIT
Just something I found that maybe help someone to help me
If I comment out this line:
#import "twitter/bootstrap/responsive";
my div.content keeps the 950px width but my html loses its responsive behavior, which I don't want
EDIT 2
The html markup:
<html>
<body>
<div class="container">
<div class="row">
<div class="span12">
<%= Content goes here %>
</div>
</div>
</div>
</body>
</html>
but on the browser it creates this things:
body = 100% width, on chrome 1280px
.container = width 1170px
.row = width 1200px
.span12 = width 1170px
Just to clarify, this is not a problem on twitter bootstrap, this is a problem on twitter-bootstrap-rails
The way I found to fix it on development is open the twitter-bootstrap-rails gem with gem-open and change the file: /vendor/toolkit/twitter/bootstrap/responsive.less commenting out these lines:
// LARGE DESKTOP & UP
// ------------------
#media (min-width: 1200px) {
// Fixed grid
#grid > .core(70px, 30px);
// Fluid grid
#grid > .fluid(5.982905983%, 2.564102564%);
// Input grid
#grid > .input(70px, 30px);
// Thumbnails
.thumbnails {
margin-left: -30px;
}
.thumbnails > li {
margin-left: 30px;
}
}
You could use the wrapper this will give you a default size of 940px.
<body>
<div class="container">
...
</div>
</body>
But if you are looking to a custom width, you should add some css in your application.css like this:
body .container{
width:980px;
}
Check it out here: Bootstrap - Layout
A nice tutorial for layout: Filling layout with bootstrap
Be sure to wrap your layout with <div class="container">, which will create a fixed layout that is centered. If this doesn't work, then perhaps something else is wrong with your layout. Please update your question with your layout HTML if this is the case.
Documentation: http://twitter.github.com/bootstrap/scaffolding.html#layouts
At the start of your responsive media queries (before ANY of them), set your element to have a "max-width"
body{max-width:1200px;margin:0px auto;}
Your site will still be responsive when you decrease browser width, but if you open up larger than 1200px (many decent widescreen displays) then it will stay as a 1200px container.
To keep it centred as it goes over 1200px add the following to the same container
body{max-width:1200px;margin:0px auto;}
The above adds "auto" margin to the left and right hand side of the element, which means means it becomes centred... (the 0px just means top and bottom are no margin, you could add some if you wanted/needed.
Note you don't have to add all that to body, but it just means it gets it out of the way at a high level....
Apparently it was a bug in the version of twitter-bootstrap gem i was using.
I dropped that project so i cant test in that environment anymore, and in some new project that i tried twitter-bootstrap again and didn't see this error again.
So i guess it is closed.
thanks for everyone

Is there a difference between .ui-widget :active and .ui-widget:active?

I am experiencing a very odd bug with Chrome 17.0.963.56. Following is a screenshot:
When the page first renders, the Salutation combobox looks fine. However as soon as you check the checkbox above, the weird image appears. Clicking anywhere on the page then causes it to go away. Unchecking the box causes it to appear again. I tried to repro in jsfiddle, but could not.
I found 2 different ways to make this bug go away. The first has to do with the HTML and CSS structure of the combobox:
<div class="field ui-helper-clearfix #Html.IdFor(m => m.Salutation)-field">
<span class="label">
#Html.LabelFor(m => m.Salutation)
</span>
<div class="input">
<div class="combobox">
<div class="text-box input">
#Html.EditorFor(m => m.Salutation)
</div>
<a class="text-box down-arrow">
<img class="text-box down-arrow" alt=""
src="/content/icons/transparent.png">
</a>
<div class="autocomplete-menu">
</div>
</div>
<div class="messages">
<div class="top callout border">
<div class="top callout bg">
</div>
</div>
<span class="validation">
#Html.ValidationMessageFor(m => m.Salutation)
</span>
</div>
</div>
</div>
.combobox .text-box.input {
position: absolute;
left: 0;
right: 20px;
border-right-color: transparent; /* was border-right-width: 0; */
border-right-width: 0;
border-radius: 5px 0 0 5px;
-moz-border-radius: 5px 0 0 5px;
}
Basically, the border comes from a div wrapper around the input element. The input itself has no border. For normal text box wrappers, the border radius is 5px. However for the combobox, I override that CSS value to give the top & bottom right corners a radius of zero. This is to make it blend into the drop-arrow element for the combobox.
When I completely remove the right border on the textbox wrapper (using border-right-width: 0;), the anomaly appears. When I instead keep the right border and give it a transparent background color, the anomaly goes away.
However I also discovered that removing /content/themes/base/jquery.ui.all.css made the problem go away. Trial and error led me to the following line in jquery.ui.theme.css:
.ui-widget :active { outline: none; }
When I remove this line, or change it to .ui-widget:active { outline: none; } (note the absence of the space between widget and :active) the problem also goes away -- even with the text box wrapper having a right border width of zero.
This issue does not occur in Firefox, IE, or Safari 5.1.1 (7534.51.22), only in the Chrome version mentioned above. So it seems it could be a Chrome bug.
I have never seen a state selector used with a space like that before. Most of the time, things like :hover, :link, :active, etc, come immediately after the selector. Does the jQuery UI selector above mean "apply outline:none; to all :active elements nested beneath a .ui-widget element"? Or does it mean "apply outline:none; to all :active .ui-widget elements"? If there is no difference by removing the space between .ui-widget and :active, I would prefer that solution over making the text box wrapper right border transparent instead of giving it a width of zero.
Another odd thing is that the Suffix combobox is not affected -- yet it uses the same exact CSS and HTML structure as the Salutation combobox. Weird...
Is there a difference between .ui-widget :active and .ui-widget:active?
There is. .ui-widget :active means "an active successor of an element with the class "ui-widget". .ui-widget:active means "an active element with the class "ui-widget".
Provided that other browsers render this case correctly, I suggest reporting a bug against Chrome (preferably, give a reduced test case): http://new.crbug.com

Resources