[Tex/LaTex] How to align fancy footer and header with text

fancyhdrheader-footer

I use fancyhdr for customized headers/footers. I have the following code :

\pagestyle{fancy}
\renewcommand{\sectionmark}[1]{\markright{\thesection.\ #1}}
\renewcommand{\chaptermark}[1]{\markboth{\chaptername\ \thechapter.\ #1}{}}
\fancyhead{} 
\fancyfoot{}
\fancyheadoffset[L]{\dimexpr\marginparsep+\marginparwidth}
\fancyhead[LE]{\leftmark}
\fancyhead[RO]{\rightmark}
\fancyfoot[LE,RO]{|\quad\thepage\quad |}

Before I added this :

\fancyheadoffset[L]{\dimexpr\marginparsep+\marginparwidth}

Each the headers/footers dont align with my text.I have a twosided scrreprt.
What i want to achieve is that on odd page numbers the header should align left and even page numbers on the right.And the same for the footer.Like this :
enter image description here

When

 \fancyheadoffset[L]{\dimexpr\marginparsep+\marginparwidth}

is added, the footers seems to be ok (WHY ?) and on even page numbers also, but on odd page numbers it is not aligned.
Like this :
enter image description here

Best Answer

I solved my problem by adding this :

 \fancyheadoffset[L]{0pt}