/    Sign up×
Community /Pin to ProfileBookmark

Coding a responsive site using CSS

Hello.

I am coding a responsive website using CSS. I intend the content of the left side bar to appear below the main content on a mobile device. Could you please help me to code it?

Here is my current code:

Thank you.

HTML file:

[CODE]
<html>
<head>

<link rel=”stylesheet” media=”screen and (min-width: 600px)” href=”file.css” />
<link rel=”stylesheet” media=”screen and (max-width: 600px)” href=”mobile.css” />

</head>
<body>

<div id=”sidebar-left”>
<h2>A Left Sidebar</h2>
</div>

<div id=”content”>
<h2>Main Content</h2>
</div>

</body>
</html>
[/CODE]

file.css

[CODE]
#sidebar-left{
width: 20%;
float: left;
margin-right: 5%;
margin-left: 5%;
background-color:blue;
}

#content{
width: 65%;
margin-right: 5%;
float: left;
background-color:red;
}
[/CODE]

mobile.css

[CODE]
#content{
width: 97%;
margin-right: 1.5%;
margin-left: 1.5%;
background-color:red;
}

#sidebar-left{
display: none;
}
[/CODE]

to post a comment
CSS

1 Comments(s)

Copy linkTweet thisAlerts:
@SempervivumApr 09.2020 — Use flex layout instead of float. Then you can both:
  • 1. switch the arrangement from horizontal to vertical by `flex-direction</C>.</LI>
    <LI>2. change the sequence of the elements by <C>
    order`
    .

    https://css-tricks.com/snippets/css/a-guide-to-flexbox/

    Good luck!
  • ×

    Success!

    Help @codewitch spread the word by sharing this article on Twitter...

    Tweet This
    Sign in
    Forgot password?
    Sign in with TwitchSign in with GithubCreate Account
    about: ({
    version: 0.1.9 BETA 5.19,
    whats_new: community page,
    up_next: more Davinci•003 tasks,
    coming_soon: events calendar,
    social: @webDeveloperHQ
    });

    legal: ({
    terms: of use,
    privacy: policy
    });
    changelog: (
    version: 0.1.9,
    notes: added community page

    version: 0.1.8,
    notes: added Davinci•003

    version: 0.1.7,
    notes: upvote answers to bounties

    version: 0.1.6,
    notes: article editor refresh
    )...
    recent_tips: (
    tipper: @AriseFacilitySolutions09,
    tipped: article
    amount: 1000 SATS,

    tipper: @Yussuf4331,
    tipped: article
    amount: 1000 SATS,

    tipper: @darkwebsites540,
    tipped: article
    amount: 10 SATS,
    )...