How could I possibly align DIVs horizontally? [closed] - html

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions must demonstrate a minimal understanding of the problem being solved. Tell us what you've tried to do, why it didn't work, and how it should work. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I've been searching everywhere and trying many things myself as to how I could possibly align DIVs horizontally. I'm probably thinking this in the wrong way but I could love to recreate this inside a web browser that will fit itself to the user's browser size, and when brought down to a certain size, such as an iPhone or other smart phones, it would change to another layout.
Here is an example of what I mean.
Thanks for your help!

For putting divs next to each other you are going to want to use float: left;
<div id=container>
<div class="section"></div>
<div class="section"></div>
<div class="section"></div>
<div class="section"></div>
</div>
Then in css:
#container {
width: 1000px;
}
.section {
position: relative;
float: left;
width: 248px;
border: 1px solid black;
}
Here is an Example
If you want things to be responsive there are a couple different options depending on what you want to do. The most effective way is probably to look in to the #media tag. Link
UPDATE:
Here is another example where the divs will automatically scale to the browser width.
Example

Related

Center an image in jQuery Mobile [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 4 years ago.
Improve this question
I am attempting to center in image in jQuery mobile using CSS. No matter what styles I apply to the image it will not center. Please not the extremes in the css were to see if the image is even being manipulated but it is not. It remains in the same position. I have tried adding a class to the image itself and aligning it center but that did not work either.
HTML:
<div class="me">
<h2 class="name">John Doe</h2>
<img src="MyPic1.jpg" alt="My Photo" height="200px"/>
</div>
CSS:
.me{text-align:center;
padding-left: 50px;
margin-left: 100px;}
Did you try change your css to
.me img{text-align:center;
padding-left: 50px;
margin-left: 100px;}
Maybe its just something what rewriting your css. You can try position relative and then give it left: 0; right: 0; and text-align: center;

How is max width being set on this site? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this question
This site: http://www.samuelgrant.co.uk
This is exactly the kind of setup I want to build. I'm stuck, however, at figuring out how the maximum width of this site is being set. I want a centered main content area like this site has with the background stretching to full browser width. Can anyone enlighten me? Relative newbie here...any help would be appreciated. Thanks!
HTML
<div class="container">
<div class="inner-w">
Stuff in your inner column
</div>
</div>
CSS
body {
margin: 0;
}
.container {
background-color: #f06;
}
.container .inner-w {
max-width: 50em; /* or 400px etc */
margin-right: auto;
margin-left: auto;
}
a jsFiddle that also shows this column width - and how it can be different in each sections etc.

How can I best port a frame-based "HTML of yesteryear" application to modern CSS(3)? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
I have an old HTML-based webapp that I am modernizing, and I wanted to see if there was anything better than my off-the-cuff CSS use to find an equivalent for the frames.
To simplify slightly, there are three roughly equal frames side by side. All three of them scroll vertically. The best approach I can think of now is to float everything left, with appropriate width and margin-left, and use overflow-y (and, where horizontal scrolling makes sense, overflow-x) settings for the DIVs in question.
Is "float everything left and set width and margin-left" optimal, and if not, what would be a more idiomatic way to replace the frames?
Thanks,
Replacing frames is tricky if the different frames use different style sheets, JS and what not.
If that is not an issue in your case and you can just copy the relavent part of the HTML from the three frames to one new HTML page with three vertical DIV's of some sort then I would suggest that you use something the overflow technique that you described. Position them absolutely with a width of 33% and a height of 100%.
You could use floats, but that might result in all kinds of annoying issues. In yoru case I'd go for position: absolute
<div class="c c1">
loooooong content
</div>
<div class="c c2">
loooooong content
</div>
<div class="c c3">
loooooong content
</div>
.c {
position: absolute;
width: 33%;
height: 100%;
top: 0;
overflow-y: scroll;
}
.c1 {
left: 0;
}
.c2 {
left: 33%;
}
.c3 {
left: 66%;
width: 34%;
}
here's a jsfiddle: http://jsfiddle.net/9CAYb/

Image and Text aligning [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I have a html page wherein Image and Text come adjacent to each other, as shown in the markup below:
<div><img src="image1.png"/><p>First Image</p></div>
<div><img src="image1.png"/><p>First Image</p></div>
I want the Image and text align side by side under every DIV and all divs to be listed in the page.
Please help me how to achieve this with CSS, without using tables.
I would use display: inline-block
img {
width: 100px;
display: inline-block;
}
p {
display: inline-block;
}
DEMO jsFiddle
If i am understanding you right, you wan't your text to be inline with your image. well if that's the case then the reason this doesn't happen already is becuase a paragraph <p> element is a block element so it would be the whole width of its containing parent. If you wan't to display it inline use display inline on your <p> tag like this
div p{ /* Change this according to your selectors. */
display: inline;
}
div{
overflow:hidden;
display:inline;
}
div img{
display:inline-block;
}
div p{
display:inline-block;
}

Customizing <div> borders using CSS [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions must demonstrate a minimal understanding of the problem being solved. Tell us what you've tried to do, why it didn't work, and how it should work. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I am trying to create a web page that looks like like in this site:
I tried creating an image with that design(the one in the middle with a white background and pointy edges on the top and bottom) but the result is that the image is static and does not dynamically change when the content of the page changes.
I do not know if I can implement the design by customizing the <div> borders or upload the design as a background image then dynamically create it.
Thanks for all the help.
If you don't want to use CSS3 (for more browser support) use the following structure:
<div class="conatiner">
<div class="pointyHeader"></div>
<div class="content">
your dynamic content here
</div>
<div class="pointyFooter"></div>
</div>
where pointyHeader and pointyFooter have a fixed height and background image.
Working jsFiddle
I thought of a .box { position: relative; }
and a .top { position: absolute; top: 0; } and same with bottom .bottom { position: absolute; bottom: 0;}
check it here: http://jsfiddle.net/DyG8F/